tokentracker-cli 0.2.23
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/LICENSE +21 -0
- package/README.md +136 -0
- package/README.old.md +324 -0
- package/README.zh-CN.md +440 -0
- package/bin/tracker.js +28 -0
- package/dashboard/dist/apple-touch-icon.png +0 -0
- package/dashboard/dist/assets/AsciiBox-vyDhXYY5.js +1 -0
- package/dashboard/dist/assets/DashboardPage-CrplxZFL.js +12 -0
- package/dashboard/dist/assets/LandingExtras-DlrtqIDj.js +1 -0
- package/dashboard/dist/assets/LeaderboardPage-Czwkjje0.js +1 -0
- package/dashboard/dist/assets/LeaderboardProfilePage-C4rorru6.js +1 -0
- package/dashboard/dist/assets/MatrixRain-bGmRmuOW.js +1 -0
- package/dashboard/dist/assets/MatrixShell-BfOGBm5o.js +1 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-400-normal-BPBWmzPh.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-400-normal-Ce5q_31Z.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-500-normal-CJBLNVQT.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-500-normal-mNhfPmgl.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-700-normal-DH5Q319x.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-700-normal-VCNRadI3.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-900-normal-BKC3PZkM.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-900-normal-DdrQ8KBw.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-400-normal-CoULgQGM.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-400-normal-LC9RFr9I.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-500-normal-D3o2eNa9.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-500-normal-DOxI7kZ4.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-700-normal-D6izGJRP.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-700-normal-QGw08Lff.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-900-normal-CmoKXrdK.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-900-normal-Cu5MFKsu.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-400-normal-Cgks_Qgx.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-400-normal-CxNRRMGd.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-500-normal-CQcGuCNt.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-500-normal-diTenJ8L.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-700-normal-BX9f1BHp.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-700-normal-YOllDaLV.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-900-normal-Br6WNUGb.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-900-normal-CrmBTzU2.woff2 +0 -0
- package/dashboard/dist/assets/index-BeoRn2gJ.js +2 -0
- package/dashboard/dist/assets/main-BYPG1_bI.js +2056 -0
- package/dashboard/dist/assets/main-hwTpulbk.css +1 -0
- package/dashboard/dist/favicon-16.png +0 -0
- package/dashboard/dist/favicon-32.png +0 -0
- package/dashboard/dist/favicon.ico +0 -0
- package/dashboard/dist/feed.xml +18 -0
- package/dashboard/dist/icon-192.png +0 -0
- package/dashboard/dist/icon-512.png +0 -0
- package/dashboard/dist/icon.svg +1 -0
- package/dashboard/dist/index.html +181 -0
- package/dashboard/dist/landing-dashboard.jpg +0 -0
- package/dashboard/dist/llms.txt +25 -0
- package/dashboard/dist/og-image.jpg +0 -0
- package/dashboard/dist/robots.txt +7 -0
- package/dashboard/dist/share-dashboard.jpg +0 -0
- package/dashboard/dist/share.html +118 -0
- package/dashboard/dist/sitemap.xml +13 -0
- package/dashboard/dist/social-preview.png +0 -0
- package/dashboard/dist/wrapped-2025.html +60 -0
- package/dashboard/dist/wrapped-2025.png +0 -0
- package/node_modules/@insforge/sdk/LICENSE +201 -0
- package/node_modules/@insforge/sdk/README.md +259 -0
- package/node_modules/@insforge/sdk/dist/index.d.mts +854 -0
- package/node_modules/@insforge/sdk/dist/index.d.ts +854 -0
- package/node_modules/@insforge/sdk/dist/index.js +1823 -0
- package/node_modules/@insforge/sdk/dist/index.js.map +1 -0
- package/node_modules/@insforge/sdk/dist/index.mjs +1784 -0
- package/node_modules/@insforge/sdk/dist/index.mjs.map +1 -0
- package/node_modules/@insforge/sdk/package.json +68 -0
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts +583 -0
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js +111 -0
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts +188 -0
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.js +48 -0
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts +1127 -0
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js +277 -0
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts +187 -0
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.js +105 -0
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts +144 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js +41 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.d.ts +1627 -0
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js +209 -0
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/database.schema.d.ts +263 -0
- package/node_modules/@insforge/shared-schemas/dist/database.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/database.schema.js +89 -0
- package/node_modules/@insforge/shared-schemas/dist/database.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts +4 -0
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.js +22 -0
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.d.ts +34 -0
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js +24 -0
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts +39 -0
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js +18 -0
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.d.ts +34 -0
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.js +14 -0
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/index.d.ts +19 -0
- package/node_modules/@insforge/shared-schemas/dist/index.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/index.js +19 -0
- package/node_modules/@insforge/shared-schemas/dist/index.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.d.ts +237 -0
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js +41 -0
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts +79 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.js +31 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts +940 -0
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js +50 -0
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts +395 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js +73 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts +269 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js +109 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts +166 -0
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js +49 -0
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts +39 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.js +15 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/package.json +31 -0
- package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
- package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/package.json +28 -0
- package/node_modules/@supabase/node-fetch/LICENSE.md +22 -0
- package/node_modules/@supabase/node-fetch/README.md +633 -0
- package/node_modules/@supabase/node-fetch/browser.js +22 -0
- package/node_modules/@supabase/node-fetch/lib/index.es.js +1778 -0
- package/node_modules/@supabase/node-fetch/lib/index.js +1787 -0
- package/node_modules/@supabase/node-fetch/lib/index.mjs +1776 -0
- package/node_modules/@supabase/node-fetch/package.json +80 -0
- package/node_modules/@supabase/postgrest-js/LICENSE +21 -0
- package/node_modules/@supabase/postgrest-js/README.md +56 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestBuilder.d.ts +71 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestBuilder.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestBuilder.js +222 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestBuilder.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestClient.d.ts +74 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestClient.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestClient.js +121 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestClient.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestError.d.ts +17 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestError.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestError.js +18 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestError.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestFilterBuilder.d.ts +108 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestFilterBuilder.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestFilterBuilder.js +381 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestFilterBuilder.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestQueryBuilder.d.ts +117 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestQueryBuilder.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestQueryBuilder.js +251 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestQueryBuilder.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestTransformBuilder.d.ts +157 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestTransformBuilder.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestTransformBuilder.js +226 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/PostgrestTransformBuilder.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/constants.d.ts +4 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/constants.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/constants.js +6 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/constants.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/index.d.ts +19 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/index.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/index.js +28 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/index.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/parser.d.ts +261 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/parser.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/parser.js +5 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/parser.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/result.d.ts +157 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/result.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/result.js +3 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/result.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/types.d.ts +31 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/types.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/types.js +3 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/types.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/utils.d.ts +264 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/utils.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/utils.js +3 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/select-query-parser/utils.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/types.d.ts +106 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/types.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/types.js +3 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/types.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/version.d.ts +2 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/version.d.ts.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/version.js +5 -0
- package/node_modules/@supabase/postgrest-js/dist/cjs/version.js.map +1 -0
- package/node_modules/@supabase/postgrest-js/dist/esm/wrapper.mjs +28 -0
- package/node_modules/@supabase/postgrest-js/package.json +75 -0
- package/node_modules/@supabase/postgrest-js/src/PostgrestBuilder.ts +300 -0
- package/node_modules/@supabase/postgrest-js/src/PostgrestClient.ts +192 -0
- package/node_modules/@supabase/postgrest-js/src/PostgrestError.ts +18 -0
- package/node_modules/@supabase/postgrest-js/src/PostgrestFilterBuilder.ts +604 -0
- package/node_modules/@supabase/postgrest-js/src/PostgrestQueryBuilder.ts +437 -0
- package/node_modules/@supabase/postgrest-js/src/PostgrestTransformBuilder.ts +368 -0
- package/node_modules/@supabase/postgrest-js/src/constants.ts +2 -0
- package/node_modules/@supabase/postgrest-js/src/index.ts +35 -0
- package/node_modules/@supabase/postgrest-js/src/select-query-parser/parser.ts +469 -0
- package/node_modules/@supabase/postgrest-js/src/select-query-parser/result.ts +503 -0
- package/node_modules/@supabase/postgrest-js/src/select-query-parser/types.ts +115 -0
- package/node_modules/@supabase/postgrest-js/src/select-query-parser/utils.ts +602 -0
- package/node_modules/@supabase/postgrest-js/src/types.ts +201 -0
- package/node_modules/@supabase/postgrest-js/src/version.ts +1 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +60 -0
- package/node_modules/debug/src/browser.js +271 -0
- package/node_modules/debug/src/common.js +274 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/engine.io-client/LICENSE +22 -0
- package/node_modules/engine.io-client/README.md +331 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
- package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/index.js +32 -0
- package/node_modules/engine.io-client/build/cjs/package.json +10 -0
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
- package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/cjs/util.js +65 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/index.js +15 -0
- package/node_modules/engine.io-client/build/esm/package.json +10 -0
- package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm/socket.js +727 -0
- package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm/transport.js +142 -0
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
- package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm/util.js +59 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
- package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.js +2968 -0
- package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
- package/node_modules/engine.io-client/package.json +95 -0
- package/node_modules/engine.io-parser/LICENSE +22 -0
- package/node_modules/engine.io-parser/Readme.md +158 -0
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
- package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
- package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/esm/index.js +156 -0
- package/node_modules/engine.io-parser/build/esm/package.json +8 -0
- package/node_modules/engine.io-parser/package.json +46 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/socket.io-client/LICENSE +21 -0
- package/node_modules/socket.io-client/README.md +29 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
- package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/cjs/index.js +76 -0
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
- package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/on.js +9 -0
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/cjs/socket.js +910 -0
- package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/cjs/url.js +69 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm/index.js +58 -0
- package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm/manager.js +367 -0
- package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/on.js +6 -0
- package/node_modules/socket.io-client/build/esm/package.json +5 -0
- package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm/socket.js +882 -0
- package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm/url.js +59 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
- package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.js +903 -0
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.js +4908 -0
- package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
- package/node_modules/socket.io-client/package.json +101 -0
- package/node_modules/socket.io-parser/LICENSE +20 -0
- package/node_modules/socket.io-parser/Readme.md +81 -0
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/cjs/binary.js +88 -0
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +90 -0
- package/node_modules/socket.io-parser/build/cjs/index.js +321 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +55 -0
- package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm/index.d.ts +90 -0
- package/node_modules/socket.io-parser/build/esm/index.js +311 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +90 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.js +316 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
- package/node_modules/socket.io-parser/package.json +58 -0
- package/node_modules/tr46/.npmignore +4 -0
- package/node_modules/tr46/index.js +193 -0
- package/node_modules/tr46/lib/.gitkeep +0 -0
- package/node_modules/tr46/lib/mappingTable.json +1 -0
- package/node_modules/tr46/package.json +31 -0
- package/node_modules/webidl-conversions/LICENSE.md +12 -0
- package/node_modules/webidl-conversions/README.md +53 -0
- package/node_modules/webidl-conversions/lib/index.js +189 -0
- package/node_modules/webidl-conversions/package.json +23 -0
- package/node_modules/whatwg-url/LICENSE.txt +21 -0
- package/node_modules/whatwg-url/README.md +67 -0
- package/node_modules/whatwg-url/lib/URL-impl.js +200 -0
- package/node_modules/whatwg-url/lib/URL.js +196 -0
- package/node_modules/whatwg-url/lib/public-api.js +11 -0
- package/node_modules/whatwg-url/lib/url-state-machine.js +1297 -0
- package/node_modules/whatwg-url/lib/utils.js +20 -0
- package/node_modules/whatwg-url/package.json +32 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +13 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +12 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +514 -0
- package/node_modules/ws/lib/receiver.js +704 -0
- package/node_modules/ws/lib/sender.js +497 -0
- package/node_modules/ws/lib/stream.js +159 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +130 -0
- package/node_modules/ws/lib/websocket-server.js +540 -0
- package/node_modules/ws/lib/websocket.js +1338 -0
- package/node_modules/ws/package.json +69 -0
- package/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
- package/node_modules/xmlhttprequest-ssl/README.md +67 -0
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
- package/node_modules/xmlhttprequest-ssl/package.json +40 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +208 -0
- package/node_modules/zod/index.cjs +33 -0
- package/node_modules/zod/index.d.cts +4 -0
- package/node_modules/zod/index.d.ts +4 -0
- package/node_modules/zod/index.js +4 -0
- package/node_modules/zod/package.json +118 -0
- package/node_modules/zod/src/index.ts +4 -0
- package/node_modules/zod/src/v3/ZodError.ts +330 -0
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
- package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
- package/node_modules/zod/src/v3/errors.ts +13 -0
- package/node_modules/zod/src/v3/external.ts +6 -0
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/node_modules/zod/src/v3/helpers/util.ts +224 -0
- package/node_modules/zod/src/v3/index.ts +4 -0
- package/node_modules/zod/src/v3/locales/en.ts +124 -0
- package/node_modules/zod/src/v3/standard-schema.ts +113 -0
- package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
- package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
- package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
- package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/complex.test.ts +56 -0
- package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
- package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
- package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
- package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +257 -0
- package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
- package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
- package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
- package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
- package/node_modules/zod/src/v3/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
- package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
- package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
- package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
- package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
- package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
- package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
- package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
- package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
- package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
- package/node_modules/zod/src/v3/types.ts +5136 -0
- package/node_modules/zod/src/v4/classic/checks.ts +30 -0
- package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
- package/node_modules/zod/src/v4/classic/compat.ts +66 -0
- package/node_modules/zod/src/v4/classic/errors.ts +75 -0
- package/node_modules/zod/src/v4/classic/external.ts +50 -0
- package/node_modules/zod/src/v4/classic/index.ts +5 -0
- package/node_modules/zod/src/v4/classic/iso.ts +90 -0
- package/node_modules/zod/src/v4/classic/parse.ts +33 -0
- package/node_modules/zod/src/v4/classic/schemas.ts +2054 -0
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +210 -0
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +63 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +352 -0
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +31 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +296 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +313 -0
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +619 -0
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +527 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +91 -0
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +268 -0
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +829 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +34 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +171 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +108 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +92 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +196 -0
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +86 -0
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +247 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +563 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +123 -0
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +147 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +37 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +298 -0
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +342 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +356 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +532 -0
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +204 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +179 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +881 -0
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +758 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2314 -0
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +250 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +163 -0
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +94 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/node_modules/zod/src/v4/core/api.ts +1594 -0
- package/node_modules/zod/src/v4/core/checks.ts +1283 -0
- package/node_modules/zod/src/v4/core/config.ts +15 -0
- package/node_modules/zod/src/v4/core/core.ts +134 -0
- package/node_modules/zod/src/v4/core/doc.ts +44 -0
- package/node_modules/zod/src/v4/core/errors.ts +424 -0
- package/node_modules/zod/src/v4/core/function.ts +176 -0
- package/node_modules/zod/src/v4/core/index.ts +15 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +143 -0
- package/node_modules/zod/src/v4/core/parse.ts +94 -0
- package/node_modules/zod/src/v4/core/regexes.ts +135 -0
- package/node_modules/zod/src/v4/core/registries.ts +96 -0
- package/node_modules/zod/src/v4/core/schemas.ts +3842 -0
- package/node_modules/zod/src/v4/core/standard-schema.ts +64 -0
- package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +977 -0
- package/node_modules/zod/src/v4/core/util.ts +775 -0
- package/node_modules/zod/src/v4/core/versions.ts +5 -0
- package/node_modules/zod/src/v4/core/zsf.ts +323 -0
- package/node_modules/zod/src/v4/index.ts +4 -0
- package/node_modules/zod/src/v4/locales/ar.ts +125 -0
- package/node_modules/zod/src/v4/locales/az.ts +121 -0
- package/node_modules/zod/src/v4/locales/be.ts +184 -0
- package/node_modules/zod/src/v4/locales/ca.ts +127 -0
- package/node_modules/zod/src/v4/locales/cs.ts +142 -0
- package/node_modules/zod/src/v4/locales/de.ts +124 -0
- package/node_modules/zod/src/v4/locales/en.ts +127 -0
- package/node_modules/zod/src/v4/locales/eo.ts +125 -0
- package/node_modules/zod/src/v4/locales/es.ts +125 -0
- package/node_modules/zod/src/v4/locales/fa.ts +134 -0
- package/node_modules/zod/src/v4/locales/fi.ts +131 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +126 -0
- package/node_modules/zod/src/v4/locales/fr.ts +124 -0
- package/node_modules/zod/src/v4/locales/he.ts +125 -0
- package/node_modules/zod/src/v4/locales/hu.ts +126 -0
- package/node_modules/zod/src/v4/locales/id.ts +125 -0
- package/node_modules/zod/src/v4/locales/index.ts +39 -0
- package/node_modules/zod/src/v4/locales/it.ts +125 -0
- package/node_modules/zod/src/v4/locales/ja.ts +122 -0
- package/node_modules/zod/src/v4/locales/kh.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +131 -0
- package/node_modules/zod/src/v4/locales/mk.ts +127 -0
- package/node_modules/zod/src/v4/locales/ms.ts +124 -0
- package/node_modules/zod/src/v4/locales/nl.ts +126 -0
- package/node_modules/zod/src/v4/locales/no.ts +124 -0
- package/node_modules/zod/src/v4/locales/ota.ts +125 -0
- package/node_modules/zod/src/v4/locales/pl.ts +126 -0
- package/node_modules/zod/src/v4/locales/ps.ts +133 -0
- package/node_modules/zod/src/v4/locales/pt.ts +123 -0
- package/node_modules/zod/src/v4/locales/ru.ts +184 -0
- package/node_modules/zod/src/v4/locales/sl.ts +126 -0
- package/node_modules/zod/src/v4/locales/sv.ts +127 -0
- package/node_modules/zod/src/v4/locales/ta.ts +125 -0
- package/node_modules/zod/src/v4/locales/th.ts +126 -0
- package/node_modules/zod/src/v4/locales/tr.ts +121 -0
- package/node_modules/zod/src/v4/locales/ua.ts +126 -0
- package/node_modules/zod/src/v4/locales/ur.ts +126 -0
- package/node_modules/zod/src/v4/locales/vi.ts +125 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +123 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +125 -0
- package/node_modules/zod/src/v4/mini/checks.ts +32 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +22 -0
- package/node_modules/zod/src/v4/mini/external.ts +40 -0
- package/node_modules/zod/src/v4/mini/index.ts +3 -0
- package/node_modules/zod/src/v4/mini/iso.ts +62 -0
- package/node_modules/zod/src/v4/mini/parse.ts +1 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +1579 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +51 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +871 -0
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +185 -0
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +299 -0
- package/node_modules/zod/src/v4-mini/index.ts +1 -0
- package/node_modules/zod/v3/ZodError.cjs +138 -0
- package/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/zod/v3/ZodError.d.ts +164 -0
- package/node_modules/zod/v3/ZodError.js +133 -0
- package/node_modules/zod/v3/errors.cjs +17 -0
- package/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/zod/v3/errors.d.ts +5 -0
- package/node_modules/zod/v3/errors.js +9 -0
- package/node_modules/zod/v3/external.cjs +22 -0
- package/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/zod/v3/external.d.ts +6 -0
- package/node_modules/zod/v3/external.js +6 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/node_modules/zod/v3/helpers/util.cjs +137 -0
- package/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/zod/v3/helpers/util.d.ts +85 -0
- package/node_modules/zod/v3/helpers/util.js +133 -0
- package/node_modules/zod/v3/index.cjs +33 -0
- package/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/zod/v3/index.d.ts +4 -0
- package/node_modules/zod/v3/index.js +4 -0
- package/node_modules/zod/v3/locales/en.cjs +111 -0
- package/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/zod/v3/locales/en.d.ts +3 -0
- package/node_modules/zod/v3/locales/en.js +109 -0
- package/node_modules/zod/v3/standard-schema.cjs +2 -0
- package/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/zod/v3/standard-schema.d.ts +102 -0
- package/node_modules/zod/v3/standard-schema.js +1 -0
- package/node_modules/zod/v3/types.cjs +3775 -0
- package/node_modules/zod/v3/types.d.cts +1031 -0
- package/node_modules/zod/v3/types.d.ts +1031 -0
- package/node_modules/zod/v3/types.js +3693 -0
- package/node_modules/zod/v4/classic/checks.cjs +32 -0
- package/node_modules/zod/v4/classic/checks.d.cts +1 -0
- package/node_modules/zod/v4/classic/checks.d.ts +1 -0
- package/node_modules/zod/v4/classic/checks.js +1 -0
- package/node_modules/zod/v4/classic/coerce.cjs +47 -0
- package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
- package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
- package/node_modules/zod/v4/classic/coerce.js +17 -0
- package/node_modules/zod/v4/classic/compat.cjs +57 -0
- package/node_modules/zod/v4/classic/compat.d.cts +46 -0
- package/node_modules/zod/v4/classic/compat.d.ts +46 -0
- package/node_modules/zod/v4/classic/compat.js +27 -0
- package/node_modules/zod/v4/classic/errors.cjs +67 -0
- package/node_modules/zod/v4/classic/errors.d.cts +30 -0
- package/node_modules/zod/v4/classic/errors.d.ts +30 -0
- package/node_modules/zod/v4/classic/errors.js +41 -0
- package/node_modules/zod/v4/classic/external.cjs +70 -0
- package/node_modules/zod/v4/classic/external.d.cts +13 -0
- package/node_modules/zod/v4/classic/external.d.ts +13 -0
- package/node_modules/zod/v4/classic/external.js +18 -0
- package/node_modules/zod/v4/classic/index.cjs +33 -0
- package/node_modules/zod/v4/classic/index.d.cts +4 -0
- package/node_modules/zod/v4/classic/index.d.ts +4 -0
- package/node_modules/zod/v4/classic/index.js +4 -0
- package/node_modules/zod/v4/classic/iso.cjs +60 -0
- package/node_modules/zod/v4/classic/iso.d.cts +22 -0
- package/node_modules/zod/v4/classic/iso.d.ts +22 -0
- package/node_modules/zod/v4/classic/iso.js +30 -0
- package/node_modules/zod/v4/classic/parse.cjs +32 -0
- package/node_modules/zod/v4/classic/parse.d.cts +23 -0
- package/node_modules/zod/v4/classic/parse.d.ts +23 -0
- package/node_modules/zod/v4/classic/parse.js +6 -0
- package/node_modules/zod/v4/classic/schemas.cjs +1109 -0
- package/node_modules/zod/v4/classic/schemas.d.cts +630 -0
- package/node_modules/zod/v4/classic/schemas.d.ts +630 -0
- package/node_modules/zod/v4/classic/schemas.js +1006 -0
- package/node_modules/zod/v4/core/api.cjs +1039 -0
- package/node_modules/zod/v4/core/api.d.cts +284 -0
- package/node_modules/zod/v4/core/api.d.ts +284 -0
- package/node_modules/zod/v4/core/api.js +906 -0
- package/node_modules/zod/v4/core/checks.cjs +591 -0
- package/node_modules/zod/v4/core/checks.d.cts +278 -0
- package/node_modules/zod/v4/core/checks.d.ts +278 -0
- package/node_modules/zod/v4/core/checks.js +565 -0
- package/node_modules/zod/v4/core/core.cjs +67 -0
- package/node_modules/zod/v4/core/core.d.cts +49 -0
- package/node_modules/zod/v4/core/core.d.ts +49 -0
- package/node_modules/zod/v4/core/core.js +61 -0
- package/node_modules/zod/v4/core/doc.cjs +39 -0
- package/node_modules/zod/v4/core/doc.d.cts +14 -0
- package/node_modules/zod/v4/core/doc.d.ts +14 -0
- package/node_modules/zod/v4/core/doc.js +35 -0
- package/node_modules/zod/v4/core/errors.cjs +226 -0
- package/node_modules/zod/v4/core/errors.d.cts +208 -0
- package/node_modules/zod/v4/core/errors.d.ts +208 -0
- package/node_modules/zod/v4/core/errors.js +195 -0
- package/node_modules/zod/v4/core/function.cjs +102 -0
- package/node_modules/zod/v4/core/function.d.cts +52 -0
- package/node_modules/zod/v4/core/function.d.ts +52 -0
- package/node_modules/zod/v4/core/function.js +75 -0
- package/node_modules/zod/v4/core/index.cjs +44 -0
- package/node_modules/zod/v4/core/index.d.cts +15 -0
- package/node_modules/zod/v4/core/index.d.ts +15 -0
- package/node_modules/zod/v4/core/index.js +15 -0
- package/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +87 -0
- package/node_modules/zod/v4/core/json-schema.d.ts +87 -0
- package/node_modules/zod/v4/core/json-schema.js +1 -0
- package/node_modules/zod/v4/core/parse.cjs +87 -0
- package/node_modules/zod/v4/core/parse.d.cts +25 -0
- package/node_modules/zod/v4/core/parse.d.ts +25 -0
- package/node_modules/zod/v4/core/parse.js +57 -0
- package/node_modules/zod/v4/core/regexes.cjs +103 -0
- package/node_modules/zod/v4/core/regexes.d.cts +62 -0
- package/node_modules/zod/v4/core/regexes.d.ts +62 -0
- package/node_modules/zod/v4/core/regexes.js +95 -0
- package/node_modules/zod/v4/core/registries.cjs +56 -0
- package/node_modules/zod/v4/core/registries.d.cts +35 -0
- package/node_modules/zod/v4/core/registries.d.ts +35 -0
- package/node_modules/zod/v4/core/registries.js +51 -0
- package/node_modules/zod/v4/core/schemas.cjs +1748 -0
- package/node_modules/zod/v4/core/schemas.d.cts +1041 -0
- package/node_modules/zod/v4/core/schemas.d.ts +1041 -0
- package/node_modules/zod/v4/core/schemas.js +1717 -0
- package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +55 -0
- package/node_modules/zod/v4/core/standard-schema.d.ts +55 -0
- package/node_modules/zod/v4/core/standard-schema.js +1 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +854 -0
- package/node_modules/zod/v4/core/to-json-schema.d.cts +88 -0
- package/node_modules/zod/v4/core/to-json-schema.d.ts +88 -0
- package/node_modules/zod/v4/core/to-json-schema.js +849 -0
- package/node_modules/zod/v4/core/util.cjs +539 -0
- package/node_modules/zod/v4/core/util.d.cts +183 -0
- package/node_modules/zod/v4/core/util.d.ts +183 -0
- package/node_modules/zod/v4/core/util.js +493 -0
- package/node_modules/zod/v4/core/versions.cjs +8 -0
- package/node_modules/zod/v4/core/versions.d.cts +5 -0
- package/node_modules/zod/v4/core/versions.d.ts +5 -0
- package/node_modules/zod/v4/core/versions.js +5 -0
- package/node_modules/zod/v4/index.cjs +22 -0
- package/node_modules/zod/v4/index.d.cts +3 -0
- package/node_modules/zod/v4/index.d.ts +3 -0
- package/node_modules/zod/v4/index.js +3 -0
- package/node_modules/zod/v4/locales/ar.cjs +142 -0
- package/node_modules/zod/v4/locales/ar.d.cts +4 -0
- package/node_modules/zod/v4/locales/ar.d.ts +4 -0
- package/node_modules/zod/v4/locales/ar.js +116 -0
- package/node_modules/zod/v4/locales/az.cjs +141 -0
- package/node_modules/zod/v4/locales/az.d.cts +4 -0
- package/node_modules/zod/v4/locales/az.d.ts +4 -0
- package/node_modules/zod/v4/locales/az.js +115 -0
- package/node_modules/zod/v4/locales/be.cjs +190 -0
- package/node_modules/zod/v4/locales/be.d.cts +4 -0
- package/node_modules/zod/v4/locales/be.d.ts +4 -0
- package/node_modules/zod/v4/locales/be.js +164 -0
- package/node_modules/zod/v4/locales/ca.cjs +144 -0
- package/node_modules/zod/v4/locales/ca.d.cts +4 -0
- package/node_modules/zod/v4/locales/ca.d.ts +4 -0
- package/node_modules/zod/v4/locales/ca.js +118 -0
- package/node_modules/zod/v4/locales/cs.cjs +161 -0
- package/node_modules/zod/v4/locales/cs.d.cts +4 -0
- package/node_modules/zod/v4/locales/cs.d.ts +4 -0
- package/node_modules/zod/v4/locales/cs.js +135 -0
- package/node_modules/zod/v4/locales/de.cjs +142 -0
- package/node_modules/zod/v4/locales/de.d.cts +4 -0
- package/node_modules/zod/v4/locales/de.d.ts +4 -0
- package/node_modules/zod/v4/locales/de.js +116 -0
- package/node_modules/zod/v4/locales/en.cjs +145 -0
- package/node_modules/zod/v4/locales/en.d.cts +5 -0
- package/node_modules/zod/v4/locales/en.d.ts +5 -0
- package/node_modules/zod/v4/locales/en.js +117 -0
- package/node_modules/zod/v4/locales/eo.cjs +144 -0
- package/node_modules/zod/v4/locales/eo.d.cts +5 -0
- package/node_modules/zod/v4/locales/eo.d.ts +5 -0
- package/node_modules/zod/v4/locales/eo.js +116 -0
- package/node_modules/zod/v4/locales/es.cjs +143 -0
- package/node_modules/zod/v4/locales/es.d.cts +4 -0
- package/node_modules/zod/v4/locales/es.d.ts +4 -0
- package/node_modules/zod/v4/locales/es.js +117 -0
- package/node_modules/zod/v4/locales/fa.cjs +148 -0
- package/node_modules/zod/v4/locales/fa.d.cts +4 -0
- package/node_modules/zod/v4/locales/fa.d.ts +4 -0
- package/node_modules/zod/v4/locales/fa.js +122 -0
- package/node_modules/zod/v4/locales/fi.cjs +148 -0
- package/node_modules/zod/v4/locales/fi.d.cts +4 -0
- package/node_modules/zod/v4/locales/fi.d.ts +4 -0
- package/node_modules/zod/v4/locales/fi.js +122 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +143 -0
- package/node_modules/zod/v4/locales/fr-CA.d.cts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.js +117 -0
- package/node_modules/zod/v4/locales/fr.cjs +142 -0
- package/node_modules/zod/v4/locales/fr.d.cts +4 -0
- package/node_modules/zod/v4/locales/fr.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr.js +116 -0
- package/node_modules/zod/v4/locales/he.cjs +143 -0
- package/node_modules/zod/v4/locales/he.d.cts +4 -0
- package/node_modules/zod/v4/locales/he.d.ts +4 -0
- package/node_modules/zod/v4/locales/he.js +117 -0
- package/node_modules/zod/v4/locales/hu.cjs +143 -0
- package/node_modules/zod/v4/locales/hu.d.cts +4 -0
- package/node_modules/zod/v4/locales/hu.d.ts +4 -0
- package/node_modules/zod/v4/locales/hu.js +117 -0
- package/node_modules/zod/v4/locales/id.cjs +142 -0
- package/node_modules/zod/v4/locales/id.d.cts +4 -0
- package/node_modules/zod/v4/locales/id.d.ts +4 -0
- package/node_modules/zod/v4/locales/id.js +116 -0
- package/node_modules/zod/v4/locales/index.cjs +84 -0
- package/node_modules/zod/v4/locales/index.d.cts +39 -0
- package/node_modules/zod/v4/locales/index.d.ts +39 -0
- package/node_modules/zod/v4/locales/index.js +39 -0
- package/node_modules/zod/v4/locales/it.cjs +143 -0
- package/node_modules/zod/v4/locales/it.d.cts +4 -0
- package/node_modules/zod/v4/locales/it.d.ts +4 -0
- package/node_modules/zod/v4/locales/it.js +117 -0
- package/node_modules/zod/v4/locales/ja.cjs +141 -0
- package/node_modules/zod/v4/locales/ja.d.cts +4 -0
- package/node_modules/zod/v4/locales/ja.d.ts +4 -0
- package/node_modules/zod/v4/locales/ja.js +115 -0
- package/node_modules/zod/v4/locales/kh.cjs +143 -0
- package/node_modules/zod/v4/locales/kh.d.cts +4 -0
- package/node_modules/zod/v4/locales/kh.d.ts +4 -0
- package/node_modules/zod/v4/locales/kh.js +117 -0
- package/node_modules/zod/v4/locales/ko.cjs +147 -0
- package/node_modules/zod/v4/locales/ko.d.cts +4 -0
- package/node_modules/zod/v4/locales/ko.d.ts +4 -0
- package/node_modules/zod/v4/locales/ko.js +121 -0
- package/node_modules/zod/v4/locales/mk.cjs +144 -0
- package/node_modules/zod/v4/locales/mk.d.cts +4 -0
- package/node_modules/zod/v4/locales/mk.d.ts +4 -0
- package/node_modules/zod/v4/locales/mk.js +118 -0
- package/node_modules/zod/v4/locales/ms.cjs +142 -0
- package/node_modules/zod/v4/locales/ms.d.cts +4 -0
- package/node_modules/zod/v4/locales/ms.d.ts +4 -0
- package/node_modules/zod/v4/locales/ms.js +116 -0
- package/node_modules/zod/v4/locales/nl.cjs +143 -0
- package/node_modules/zod/v4/locales/nl.d.cts +4 -0
- package/node_modules/zod/v4/locales/nl.d.ts +4 -0
- package/node_modules/zod/v4/locales/nl.js +117 -0
- package/node_modules/zod/v4/locales/no.cjs +142 -0
- package/node_modules/zod/v4/locales/no.d.cts +4 -0
- package/node_modules/zod/v4/locales/no.d.ts +4 -0
- package/node_modules/zod/v4/locales/no.js +116 -0
- package/node_modules/zod/v4/locales/ota.cjs +143 -0
- package/node_modules/zod/v4/locales/ota.d.cts +4 -0
- package/node_modules/zod/v4/locales/ota.d.ts +4 -0
- package/node_modules/zod/v4/locales/ota.js +117 -0
- package/node_modules/zod/v4/locales/pl.cjs +143 -0
- package/node_modules/zod/v4/locales/pl.d.cts +4 -0
- package/node_modules/zod/v4/locales/pl.d.ts +4 -0
- package/node_modules/zod/v4/locales/pl.js +117 -0
- package/node_modules/zod/v4/locales/ps.cjs +148 -0
- package/node_modules/zod/v4/locales/ps.d.cts +4 -0
- package/node_modules/zod/v4/locales/ps.d.ts +4 -0
- package/node_modules/zod/v4/locales/ps.js +122 -0
- package/node_modules/zod/v4/locales/pt.cjs +142 -0
- package/node_modules/zod/v4/locales/pt.d.cts +4 -0
- package/node_modules/zod/v4/locales/pt.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt.js +116 -0
- package/node_modules/zod/v4/locales/ru.cjs +190 -0
- package/node_modules/zod/v4/locales/ru.d.cts +4 -0
- package/node_modules/zod/v4/locales/ru.d.ts +4 -0
- package/node_modules/zod/v4/locales/ru.js +164 -0
- package/node_modules/zod/v4/locales/sl.cjs +143 -0
- package/node_modules/zod/v4/locales/sl.d.cts +4 -0
- package/node_modules/zod/v4/locales/sl.d.ts +4 -0
- package/node_modules/zod/v4/locales/sl.js +117 -0
- package/node_modules/zod/v4/locales/sv.cjs +144 -0
- package/node_modules/zod/v4/locales/sv.d.cts +4 -0
- package/node_modules/zod/v4/locales/sv.d.ts +4 -0
- package/node_modules/zod/v4/locales/sv.js +118 -0
- package/node_modules/zod/v4/locales/ta.cjs +143 -0
- package/node_modules/zod/v4/locales/ta.d.cts +4 -0
- package/node_modules/zod/v4/locales/ta.d.ts +4 -0
- package/node_modules/zod/v4/locales/ta.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +143 -0
- package/node_modules/zod/v4/locales/th.d.cts +4 -0
- package/node_modules/zod/v4/locales/th.d.ts +4 -0
- package/node_modules/zod/v4/locales/th.js +117 -0
- package/node_modules/zod/v4/locales/tr.cjs +143 -0
- package/node_modules/zod/v4/locales/tr.d.cts +5 -0
- package/node_modules/zod/v4/locales/tr.d.ts +5 -0
- package/node_modules/zod/v4/locales/tr.js +115 -0
- package/node_modules/zod/v4/locales/ua.cjs +143 -0
- package/node_modules/zod/v4/locales/ua.d.cts +4 -0
- package/node_modules/zod/v4/locales/ua.d.ts +4 -0
- package/node_modules/zod/v4/locales/ua.js +117 -0
- package/node_modules/zod/v4/locales/ur.cjs +143 -0
- package/node_modules/zod/v4/locales/ur.d.cts +4 -0
- package/node_modules/zod/v4/locales/ur.d.ts +4 -0
- package/node_modules/zod/v4/locales/ur.js +117 -0
- package/node_modules/zod/v4/locales/vi.cjs +142 -0
- package/node_modules/zod/v4/locales/vi.d.cts +4 -0
- package/node_modules/zod/v4/locales/vi.d.ts +4 -0
- package/node_modules/zod/v4/locales/vi.js +116 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +142 -0
- package/node_modules/zod/v4/locales/zh-CN.d.cts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.js +116 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +143 -0
- package/node_modules/zod/v4/locales/zh-TW.d.cts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.js +117 -0
- package/node_modules/zod/v4/mini/checks.cjs +34 -0
- package/node_modules/zod/v4/mini/checks.d.cts +1 -0
- package/node_modules/zod/v4/mini/checks.d.ts +1 -0
- package/node_modules/zod/v4/mini/checks.js +1 -0
- package/node_modules/zod/v4/mini/coerce.cjs +47 -0
- package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
- package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
- package/node_modules/zod/v4/mini/coerce.js +17 -0
- package/node_modules/zod/v4/mini/external.cjs +62 -0
- package/node_modules/zod/v4/mini/external.d.cts +11 -0
- package/node_modules/zod/v4/mini/external.d.ts +11 -0
- package/node_modules/zod/v4/mini/external.js +13 -0
- package/node_modules/zod/v4/mini/index.cjs +32 -0
- package/node_modules/zod/v4/mini/index.d.cts +3 -0
- package/node_modules/zod/v4/mini/index.d.ts +3 -0
- package/node_modules/zod/v4/mini/index.js +3 -0
- package/node_modules/zod/v4/mini/iso.cjs +60 -0
- package/node_modules/zod/v4/mini/iso.d.cts +22 -0
- package/node_modules/zod/v4/mini/iso.d.ts +22 -0
- package/node_modules/zod/v4/mini/iso.js +30 -0
- package/node_modules/zod/v4/mini/parse.cjs +8 -0
- package/node_modules/zod/v4/mini/parse.d.cts +1 -0
- package/node_modules/zod/v4/mini/parse.d.ts +1 -0
- package/node_modules/zod/v4/mini/parse.js +1 -0
- package/node_modules/zod/v4/mini/schemas.cjs +839 -0
- package/node_modules/zod/v4/mini/schemas.d.cts +356 -0
- package/node_modules/zod/v4/mini/schemas.d.ts +356 -0
- package/node_modules/zod/v4/mini/schemas.js +732 -0
- package/node_modules/zod/v4-mini/index.cjs +17 -0
- package/node_modules/zod/v4-mini/index.d.cts +1 -0
- package/node_modules/zod/v4-mini/index.d.ts +1 -0
- package/node_modules/zod/v4-mini/index.js +1 -0
- package/package.json +58 -0
- package/src/cli.js +83 -0
- package/src/commands/activate-if-needed.js +41 -0
- package/src/commands/diagnostics.js +38 -0
- package/src/commands/doctor.js +96 -0
- package/src/commands/init.js +975 -0
- package/src/commands/serve.js +200 -0
- package/src/commands/status.js +215 -0
- package/src/commands/sync.js +783 -0
- package/src/commands/uninstall.js +167 -0
- package/src/lib/activation-check.js +341 -0
- package/src/lib/browser-auth.js +177 -0
- package/src/lib/claude-config.js +190 -0
- package/src/lib/cli-ui.js +179 -0
- package/src/lib/codex-config.js +350 -0
- package/src/lib/debug-flags.js +7 -0
- package/src/lib/diagnostics.js +216 -0
- package/src/lib/doctor.js +351 -0
- package/src/lib/fs.js +77 -0
- package/src/lib/gemini-config.js +288 -0
- package/src/lib/init-flow.js +42 -0
- package/src/lib/insforge-client.js +79 -0
- package/src/lib/insforge.js +29 -0
- package/src/lib/local-api.js +511 -0
- package/src/lib/openclaw-hook.js +420 -0
- package/src/lib/openclaw-session-plugin.js +520 -0
- package/src/lib/opencode-config.js +99 -0
- package/src/lib/opencode-usage-audit.js +205 -0
- package/src/lib/progress.js +76 -0
- package/src/lib/project-usage-purge.js +106 -0
- package/src/lib/prompt.js +24 -0
- package/src/lib/rollout.js +2472 -0
- package/src/lib/runtime-config.js +132 -0
- package/src/lib/static-server.js +59 -0
- package/src/lib/subscriptions.js +319 -0
- package/src/lib/tracker-paths.js +15 -0
- package/src/lib/upload-throttle.js +148 -0
- package/src/lib/uploader.js +224 -0
- package/src/lib/vibeusage-api.js +243 -0
- package/src/lib/vibeusage-public-repo.js +105 -0
|
@@ -0,0 +1,2472 @@
|
|
|
1
|
+
const fs = require("node:fs/promises");
|
|
2
|
+
const fssync = require("node:fs");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const readline = require("node:readline");
|
|
5
|
+
const cp = require("node:child_process");
|
|
6
|
+
|
|
7
|
+
const { ensureDir } = require("./fs");
|
|
8
|
+
const { hashRepoRoot, resolveGitHubPublicStatus } = require("./vibeusage-public-repo");
|
|
9
|
+
|
|
10
|
+
const DEFAULT_SOURCE = "codex";
|
|
11
|
+
const DEFAULT_MODEL = "unknown";
|
|
12
|
+
const BUCKET_SEPARATOR = "|";
|
|
13
|
+
|
|
14
|
+
async function listRolloutFiles(sessionsDir) {
|
|
15
|
+
const out = [];
|
|
16
|
+
const years = await safeReadDir(sessionsDir);
|
|
17
|
+
for (const y of years) {
|
|
18
|
+
if (!/^[0-9]{4}$/.test(y.name) || !y.isDirectory()) continue;
|
|
19
|
+
const yearDir = path.join(sessionsDir, y.name);
|
|
20
|
+
const months = await safeReadDir(yearDir);
|
|
21
|
+
for (const m of months) {
|
|
22
|
+
if (!/^[0-9]{2}$/.test(m.name) || !m.isDirectory()) continue;
|
|
23
|
+
const monthDir = path.join(yearDir, m.name);
|
|
24
|
+
const days = await safeReadDir(monthDir);
|
|
25
|
+
for (const d of days) {
|
|
26
|
+
if (!/^[0-9]{2}$/.test(d.name) || !d.isDirectory()) continue;
|
|
27
|
+
const dayDir = path.join(monthDir, d.name);
|
|
28
|
+
const files = await safeReadDir(dayDir);
|
|
29
|
+
for (const f of files) {
|
|
30
|
+
if (!f.isFile()) continue;
|
|
31
|
+
if (!f.name.startsWith("rollout-") || !f.name.endsWith(".jsonl")) continue;
|
|
32
|
+
out.push(path.join(dayDir, f.name));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
out.sort((a, b) => a.localeCompare(b));
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function listClaudeProjectFiles(projectsDir) {
|
|
43
|
+
const out = [];
|
|
44
|
+
await walkClaudeProjects(projectsDir, out);
|
|
45
|
+
out.sort((a, b) => a.localeCompare(b));
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function listGeminiSessionFiles(tmpDir) {
|
|
50
|
+
const out = [];
|
|
51
|
+
const roots = await safeReadDir(tmpDir);
|
|
52
|
+
for (const root of roots) {
|
|
53
|
+
if (!root.isDirectory()) continue;
|
|
54
|
+
const chatsDir = path.join(tmpDir, root.name, "chats");
|
|
55
|
+
const chats = await safeReadDir(chatsDir);
|
|
56
|
+
for (const entry of chats) {
|
|
57
|
+
if (!entry.isFile()) continue;
|
|
58
|
+
if (!entry.name.startsWith("session-") || !entry.name.endsWith(".json")) continue;
|
|
59
|
+
out.push(path.join(chatsDir, entry.name));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
out.sort((a, b) => a.localeCompare(b));
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function listOpencodeMessageFiles(storageDir) {
|
|
67
|
+
const out = [];
|
|
68
|
+
const messageDir = path.join(storageDir, "message");
|
|
69
|
+
await walkOpencodeMessages(messageDir, out);
|
|
70
|
+
out.sort((a, b) => a.localeCompare(b));
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function parseRolloutIncremental({
|
|
75
|
+
rolloutFiles,
|
|
76
|
+
cursors,
|
|
77
|
+
queuePath,
|
|
78
|
+
projectQueuePath,
|
|
79
|
+
onProgress,
|
|
80
|
+
source,
|
|
81
|
+
publicRepoResolver,
|
|
82
|
+
}) {
|
|
83
|
+
await ensureDir(path.dirname(queuePath));
|
|
84
|
+
let filesProcessed = 0;
|
|
85
|
+
let eventsAggregated = 0;
|
|
86
|
+
|
|
87
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
88
|
+
const totalFiles = Array.isArray(rolloutFiles) ? rolloutFiles.length : 0;
|
|
89
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
90
|
+
const projectEnabled = typeof projectQueuePath === "string" && projectQueuePath.length > 0;
|
|
91
|
+
const projectState = projectEnabled ? normalizeProjectState(cursors?.projectHourly) : null;
|
|
92
|
+
const projectTouchedBuckets = projectEnabled ? new Set() : null;
|
|
93
|
+
const projectMetaCache = projectEnabled ? new Map() : null;
|
|
94
|
+
const publicRepoCache = projectEnabled ? new Map() : null;
|
|
95
|
+
const touchedBuckets = new Set();
|
|
96
|
+
const defaultSource = normalizeSourceInput(source) || DEFAULT_SOURCE;
|
|
97
|
+
|
|
98
|
+
if (!cursors.files || typeof cursors.files !== "object") {
|
|
99
|
+
cursors.files = {};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
for (let idx = 0; idx < rolloutFiles.length; idx++) {
|
|
103
|
+
const entry = rolloutFiles[idx];
|
|
104
|
+
const filePath = typeof entry === "string" ? entry : entry?.path;
|
|
105
|
+
if (!filePath) continue;
|
|
106
|
+
const fileSource =
|
|
107
|
+
typeof entry === "string"
|
|
108
|
+
? defaultSource
|
|
109
|
+
: normalizeSourceInput(entry?.source) || defaultSource;
|
|
110
|
+
const st = await fs.stat(filePath).catch(() => null);
|
|
111
|
+
if (!st || !st.isFile()) continue;
|
|
112
|
+
|
|
113
|
+
const key = filePath;
|
|
114
|
+
const prev = cursors.files[key] || null;
|
|
115
|
+
const inode = st.ino || 0;
|
|
116
|
+
const startOffset = prev && prev.inode === inode ? prev.offset || 0 : 0;
|
|
117
|
+
const lastTotal = prev && prev.inode === inode ? prev.lastTotal || null : null;
|
|
118
|
+
const lastModel = prev && prev.inode === inode ? prev.lastModel || null : null;
|
|
119
|
+
|
|
120
|
+
const projectContext = projectEnabled
|
|
121
|
+
? await resolveProjectContextForFile({
|
|
122
|
+
filePath,
|
|
123
|
+
projectMetaCache,
|
|
124
|
+
publicRepoCache,
|
|
125
|
+
publicRepoResolver,
|
|
126
|
+
projectState,
|
|
127
|
+
})
|
|
128
|
+
: null;
|
|
129
|
+
const projectRef = projectContext?.projectRef || null;
|
|
130
|
+
const projectKey = projectContext?.projectKey || null;
|
|
131
|
+
|
|
132
|
+
const result = await parseRolloutFile({
|
|
133
|
+
filePath,
|
|
134
|
+
startOffset,
|
|
135
|
+
lastTotal,
|
|
136
|
+
lastModel,
|
|
137
|
+
hourlyState,
|
|
138
|
+
touchedBuckets,
|
|
139
|
+
source: fileSource,
|
|
140
|
+
projectState,
|
|
141
|
+
projectTouchedBuckets,
|
|
142
|
+
projectRef,
|
|
143
|
+
projectKey,
|
|
144
|
+
projectMetaCache,
|
|
145
|
+
publicRepoCache,
|
|
146
|
+
publicRepoResolver,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
cursors.files[key] = {
|
|
150
|
+
inode,
|
|
151
|
+
offset: result.endOffset,
|
|
152
|
+
lastTotal: result.lastTotal,
|
|
153
|
+
lastModel: result.lastModel,
|
|
154
|
+
updatedAt: new Date().toISOString(),
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
filesProcessed += 1;
|
|
158
|
+
eventsAggregated += result.eventsAggregated;
|
|
159
|
+
|
|
160
|
+
if (cb) {
|
|
161
|
+
cb({
|
|
162
|
+
index: idx + 1,
|
|
163
|
+
total: totalFiles,
|
|
164
|
+
filePath,
|
|
165
|
+
filesProcessed,
|
|
166
|
+
eventsAggregated,
|
|
167
|
+
bucketsQueued: touchedBuckets.size,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
173
|
+
const projectBucketsQueued = projectEnabled
|
|
174
|
+
? await enqueueTouchedProjectBuckets({ projectQueuePath, projectState, projectTouchedBuckets })
|
|
175
|
+
: 0;
|
|
176
|
+
hourlyState.updatedAt = new Date().toISOString();
|
|
177
|
+
cursors.hourly = hourlyState;
|
|
178
|
+
if (projectState) {
|
|
179
|
+
projectState.updatedAt = new Date().toISOString();
|
|
180
|
+
cursors.projectHourly = projectState;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return { filesProcessed, eventsAggregated, bucketsQueued, projectBucketsQueued };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function parseClaudeIncremental({
|
|
187
|
+
projectFiles,
|
|
188
|
+
cursors,
|
|
189
|
+
queuePath,
|
|
190
|
+
projectQueuePath,
|
|
191
|
+
onProgress,
|
|
192
|
+
source,
|
|
193
|
+
publicRepoResolver,
|
|
194
|
+
}) {
|
|
195
|
+
await ensureDir(path.dirname(queuePath));
|
|
196
|
+
let filesProcessed = 0;
|
|
197
|
+
let eventsAggregated = 0;
|
|
198
|
+
|
|
199
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
200
|
+
const files = Array.isArray(projectFiles) ? projectFiles : [];
|
|
201
|
+
const totalFiles = files.length;
|
|
202
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
203
|
+
const projectEnabled = typeof projectQueuePath === "string" && projectQueuePath.length > 0;
|
|
204
|
+
const projectState = projectEnabled ? normalizeProjectState(cursors?.projectHourly) : null;
|
|
205
|
+
const projectTouchedBuckets = projectEnabled ? new Set() : null;
|
|
206
|
+
const projectMetaCache = projectEnabled ? new Map() : null;
|
|
207
|
+
const publicRepoCache = projectEnabled ? new Map() : null;
|
|
208
|
+
const touchedBuckets = new Set();
|
|
209
|
+
const defaultSource = normalizeSourceInput(source) || "claude";
|
|
210
|
+
|
|
211
|
+
if (!cursors.files || typeof cursors.files !== "object") {
|
|
212
|
+
cursors.files = {};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
for (let idx = 0; idx < files.length; idx++) {
|
|
216
|
+
const entry = files[idx];
|
|
217
|
+
const filePath = typeof entry === "string" ? entry : entry?.path;
|
|
218
|
+
if (!filePath) continue;
|
|
219
|
+
const fileSource =
|
|
220
|
+
typeof entry === "string"
|
|
221
|
+
? defaultSource
|
|
222
|
+
: normalizeSourceInput(entry?.source) || defaultSource;
|
|
223
|
+
const st = await fs.stat(filePath).catch(() => null);
|
|
224
|
+
if (!st || !st.isFile()) continue;
|
|
225
|
+
|
|
226
|
+
const key = filePath;
|
|
227
|
+
const prev = cursors.files[key] || null;
|
|
228
|
+
const inode = st.ino || 0;
|
|
229
|
+
const startOffset = prev && prev.inode === inode ? prev.offset || 0 : 0;
|
|
230
|
+
|
|
231
|
+
const projectContext = projectEnabled
|
|
232
|
+
? await resolveProjectContextForFile({
|
|
233
|
+
filePath,
|
|
234
|
+
projectMetaCache,
|
|
235
|
+
publicRepoCache,
|
|
236
|
+
publicRepoResolver,
|
|
237
|
+
projectState,
|
|
238
|
+
})
|
|
239
|
+
: null;
|
|
240
|
+
const projectRef = projectContext?.projectRef || null;
|
|
241
|
+
const projectKey = projectContext?.projectKey || null;
|
|
242
|
+
|
|
243
|
+
const result = await parseClaudeFile({
|
|
244
|
+
filePath,
|
|
245
|
+
startOffset,
|
|
246
|
+
hourlyState,
|
|
247
|
+
touchedBuckets,
|
|
248
|
+
source: fileSource,
|
|
249
|
+
projectState,
|
|
250
|
+
projectTouchedBuckets,
|
|
251
|
+
projectRef,
|
|
252
|
+
projectKey,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
cursors.files[key] = {
|
|
256
|
+
inode,
|
|
257
|
+
offset: result.endOffset,
|
|
258
|
+
updatedAt: new Date().toISOString(),
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
filesProcessed += 1;
|
|
262
|
+
eventsAggregated += result.eventsAggregated;
|
|
263
|
+
|
|
264
|
+
if (cb) {
|
|
265
|
+
cb({
|
|
266
|
+
index: idx + 1,
|
|
267
|
+
total: totalFiles,
|
|
268
|
+
filePath,
|
|
269
|
+
filesProcessed,
|
|
270
|
+
eventsAggregated,
|
|
271
|
+
bucketsQueued: touchedBuckets.size,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
277
|
+
const projectBucketsQueued = projectEnabled
|
|
278
|
+
? await enqueueTouchedProjectBuckets({ projectQueuePath, projectState, projectTouchedBuckets })
|
|
279
|
+
: 0;
|
|
280
|
+
hourlyState.updatedAt = new Date().toISOString();
|
|
281
|
+
cursors.hourly = hourlyState;
|
|
282
|
+
if (projectState) {
|
|
283
|
+
projectState.updatedAt = new Date().toISOString();
|
|
284
|
+
cursors.projectHourly = projectState;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return { filesProcessed, eventsAggregated, bucketsQueued, projectBucketsQueued };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async function parseGeminiIncremental({
|
|
291
|
+
sessionFiles,
|
|
292
|
+
cursors,
|
|
293
|
+
queuePath,
|
|
294
|
+
projectQueuePath,
|
|
295
|
+
onProgress,
|
|
296
|
+
source,
|
|
297
|
+
publicRepoResolver,
|
|
298
|
+
}) {
|
|
299
|
+
await ensureDir(path.dirname(queuePath));
|
|
300
|
+
let filesProcessed = 0;
|
|
301
|
+
let eventsAggregated = 0;
|
|
302
|
+
|
|
303
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
304
|
+
const files = Array.isArray(sessionFiles) ? sessionFiles : [];
|
|
305
|
+
const totalFiles = files.length;
|
|
306
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
307
|
+
const projectEnabled = typeof projectQueuePath === "string" && projectQueuePath.length > 0;
|
|
308
|
+
const projectState = projectEnabled ? normalizeProjectState(cursors?.projectHourly) : null;
|
|
309
|
+
const projectTouchedBuckets = projectEnabled ? new Set() : null;
|
|
310
|
+
const projectMetaCache = projectEnabled ? new Map() : null;
|
|
311
|
+
const publicRepoCache = projectEnabled ? new Map() : null;
|
|
312
|
+
const touchedBuckets = new Set();
|
|
313
|
+
const defaultSource = normalizeSourceInput(source) || "gemini";
|
|
314
|
+
|
|
315
|
+
if (!cursors.files || typeof cursors.files !== "object") {
|
|
316
|
+
cursors.files = {};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
for (let idx = 0; idx < files.length; idx++) {
|
|
320
|
+
const entry = files[idx];
|
|
321
|
+
const filePath = typeof entry === "string" ? entry : entry?.path;
|
|
322
|
+
if (!filePath) continue;
|
|
323
|
+
const fileSource =
|
|
324
|
+
typeof entry === "string"
|
|
325
|
+
? defaultSource
|
|
326
|
+
: normalizeSourceInput(entry?.source) || defaultSource;
|
|
327
|
+
const st = await fs.stat(filePath).catch(() => null);
|
|
328
|
+
if (!st || !st.isFile()) continue;
|
|
329
|
+
|
|
330
|
+
const key = filePath;
|
|
331
|
+
const prev = cursors.files[key] || null;
|
|
332
|
+
const inode = st.ino || 0;
|
|
333
|
+
let startIndex = prev && prev.inode === inode ? Number(prev.lastIndex || -1) : -1;
|
|
334
|
+
let lastTotals = prev && prev.inode === inode ? prev.lastTotals || null : null;
|
|
335
|
+
let lastModel = prev && prev.inode === inode ? prev.lastModel || null : null;
|
|
336
|
+
|
|
337
|
+
const projectContext = projectEnabled
|
|
338
|
+
? await resolveProjectContextForFile({
|
|
339
|
+
filePath,
|
|
340
|
+
projectMetaCache,
|
|
341
|
+
publicRepoCache,
|
|
342
|
+
publicRepoResolver,
|
|
343
|
+
projectState,
|
|
344
|
+
})
|
|
345
|
+
: null;
|
|
346
|
+
const projectRef = projectContext?.projectRef || null;
|
|
347
|
+
const projectKey = projectContext?.projectKey || null;
|
|
348
|
+
|
|
349
|
+
const result = await parseGeminiFile({
|
|
350
|
+
filePath,
|
|
351
|
+
startIndex,
|
|
352
|
+
lastTotals,
|
|
353
|
+
lastModel,
|
|
354
|
+
hourlyState,
|
|
355
|
+
touchedBuckets,
|
|
356
|
+
source: fileSource,
|
|
357
|
+
projectState,
|
|
358
|
+
projectTouchedBuckets,
|
|
359
|
+
projectRef,
|
|
360
|
+
projectKey,
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
cursors.files[key] = {
|
|
364
|
+
inode,
|
|
365
|
+
lastIndex: result.lastIndex,
|
|
366
|
+
lastTotals: result.lastTotals,
|
|
367
|
+
lastModel: result.lastModel,
|
|
368
|
+
updatedAt: new Date().toISOString(),
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
filesProcessed += 1;
|
|
372
|
+
eventsAggregated += result.eventsAggregated;
|
|
373
|
+
|
|
374
|
+
if (cb) {
|
|
375
|
+
cb({
|
|
376
|
+
index: idx + 1,
|
|
377
|
+
total: totalFiles,
|
|
378
|
+
filePath,
|
|
379
|
+
filesProcessed,
|
|
380
|
+
eventsAggregated,
|
|
381
|
+
bucketsQueued: touchedBuckets.size,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
387
|
+
const projectBucketsQueued = projectEnabled
|
|
388
|
+
? await enqueueTouchedProjectBuckets({ projectQueuePath, projectState, projectTouchedBuckets })
|
|
389
|
+
: 0;
|
|
390
|
+
hourlyState.updatedAt = new Date().toISOString();
|
|
391
|
+
cursors.hourly = hourlyState;
|
|
392
|
+
if (projectState) {
|
|
393
|
+
projectState.updatedAt = new Date().toISOString();
|
|
394
|
+
cursors.projectHourly = projectState;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return { filesProcessed, eventsAggregated, bucketsQueued, projectBucketsQueued };
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function parseOpencodeIncremental({
|
|
401
|
+
messageFiles,
|
|
402
|
+
cursors,
|
|
403
|
+
queuePath,
|
|
404
|
+
projectQueuePath,
|
|
405
|
+
onProgress,
|
|
406
|
+
source,
|
|
407
|
+
publicRepoResolver,
|
|
408
|
+
}) {
|
|
409
|
+
await ensureDir(path.dirname(queuePath));
|
|
410
|
+
let filesProcessed = 0;
|
|
411
|
+
let eventsAggregated = 0;
|
|
412
|
+
|
|
413
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
414
|
+
const files = Array.isArray(messageFiles) ? messageFiles : [];
|
|
415
|
+
const totalFiles = files.length;
|
|
416
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
417
|
+
const projectEnabled = typeof projectQueuePath === "string" && projectQueuePath.length > 0;
|
|
418
|
+
const projectState = projectEnabled ? normalizeProjectState(cursors?.projectHourly) : null;
|
|
419
|
+
const projectTouchedBuckets = projectEnabled ? new Set() : null;
|
|
420
|
+
const projectMetaCache = projectEnabled ? new Map() : null;
|
|
421
|
+
const publicRepoCache = projectEnabled ? new Map() : null;
|
|
422
|
+
const opencodeState = normalizeOpencodeState(cursors?.opencode);
|
|
423
|
+
const messageIndex = opencodeState.messages;
|
|
424
|
+
const touchedBuckets = new Set();
|
|
425
|
+
const defaultSource = normalizeSourceInput(source) || "opencode";
|
|
426
|
+
|
|
427
|
+
if (!cursors.files || typeof cursors.files !== "object") {
|
|
428
|
+
cursors.files = {};
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
for (let idx = 0; idx < files.length; idx++) {
|
|
432
|
+
const entry = files[idx];
|
|
433
|
+
const filePath = typeof entry === "string" ? entry : entry?.path;
|
|
434
|
+
if (!filePath) continue;
|
|
435
|
+
const fileSource =
|
|
436
|
+
typeof entry === "string"
|
|
437
|
+
? defaultSource
|
|
438
|
+
: normalizeSourceInput(entry?.source) || defaultSource;
|
|
439
|
+
const st = await fs.stat(filePath).catch(() => null);
|
|
440
|
+
if (!st || !st.isFile()) continue;
|
|
441
|
+
|
|
442
|
+
const key = filePath;
|
|
443
|
+
const prev = cursors.files[key] || null;
|
|
444
|
+
const inode = st.ino || 0;
|
|
445
|
+
const size = Number.isFinite(st.size) ? st.size : 0;
|
|
446
|
+
const mtimeMs = Number.isFinite(st.mtimeMs) ? st.mtimeMs : 0;
|
|
447
|
+
const unchanged =
|
|
448
|
+
prev && prev.inode === inode && prev.size === size && prev.mtimeMs === mtimeMs;
|
|
449
|
+
if (unchanged) {
|
|
450
|
+
filesProcessed += 1;
|
|
451
|
+
if (cb) {
|
|
452
|
+
cb({
|
|
453
|
+
index: idx + 1,
|
|
454
|
+
total: totalFiles,
|
|
455
|
+
filePath,
|
|
456
|
+
filesProcessed,
|
|
457
|
+
eventsAggregated,
|
|
458
|
+
bucketsQueued: touchedBuckets.size,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const fallbackTotals = prev && typeof prev.lastTotals === "object" ? prev.lastTotals : null;
|
|
465
|
+
const fallbackMessageKey =
|
|
466
|
+
prev && typeof prev.messageKey === "string" && prev.messageKey.trim()
|
|
467
|
+
? prev.messageKey.trim()
|
|
468
|
+
: null;
|
|
469
|
+
const projectContext = projectEnabled
|
|
470
|
+
? await resolveProjectContextForFile({
|
|
471
|
+
filePath,
|
|
472
|
+
projectMetaCache,
|
|
473
|
+
publicRepoCache,
|
|
474
|
+
publicRepoResolver,
|
|
475
|
+
projectState,
|
|
476
|
+
})
|
|
477
|
+
: null;
|
|
478
|
+
const projectRef = projectContext?.projectRef || null;
|
|
479
|
+
const projectKey = projectContext?.projectKey || null;
|
|
480
|
+
|
|
481
|
+
const result = await parseOpencodeMessageFile({
|
|
482
|
+
filePath,
|
|
483
|
+
messageIndex,
|
|
484
|
+
fallbackTotals,
|
|
485
|
+
fallbackMessageKey,
|
|
486
|
+
hourlyState,
|
|
487
|
+
touchedBuckets,
|
|
488
|
+
source: fileSource,
|
|
489
|
+
projectState,
|
|
490
|
+
projectTouchedBuckets,
|
|
491
|
+
projectRef,
|
|
492
|
+
projectKey,
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
cursors.files[key] = {
|
|
496
|
+
inode,
|
|
497
|
+
size,
|
|
498
|
+
mtimeMs,
|
|
499
|
+
lastTotals: result.lastTotals,
|
|
500
|
+
messageKey: result.messageKey || null,
|
|
501
|
+
updatedAt: new Date().toISOString(),
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
filesProcessed += 1;
|
|
505
|
+
eventsAggregated += result.eventsAggregated;
|
|
506
|
+
|
|
507
|
+
if (result.messageKey && result.shouldUpdate) {
|
|
508
|
+
messageIndex[result.messageKey] = {
|
|
509
|
+
lastTotals: result.lastTotals,
|
|
510
|
+
updatedAt: new Date().toISOString(),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (cb) {
|
|
515
|
+
cb({
|
|
516
|
+
index: idx + 1,
|
|
517
|
+
total: totalFiles,
|
|
518
|
+
filePath,
|
|
519
|
+
filesProcessed,
|
|
520
|
+
eventsAggregated,
|
|
521
|
+
bucketsQueued: touchedBuckets.size,
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
527
|
+
const projectBucketsQueued = projectEnabled
|
|
528
|
+
? await enqueueTouchedProjectBuckets({ projectQueuePath, projectState, projectTouchedBuckets })
|
|
529
|
+
: 0;
|
|
530
|
+
hourlyState.updatedAt = new Date().toISOString();
|
|
531
|
+
cursors.hourly = hourlyState;
|
|
532
|
+
opencodeState.updatedAt = new Date().toISOString();
|
|
533
|
+
cursors.opencode = opencodeState;
|
|
534
|
+
if (projectState) {
|
|
535
|
+
projectState.updatedAt = new Date().toISOString();
|
|
536
|
+
cursors.projectHourly = projectState;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return { filesProcessed, eventsAggregated, bucketsQueued, projectBucketsQueued };
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
async function parseOpenclawIncremental({
|
|
543
|
+
sessionFiles,
|
|
544
|
+
cursors,
|
|
545
|
+
queuePath,
|
|
546
|
+
projectQueuePath,
|
|
547
|
+
onProgress,
|
|
548
|
+
source,
|
|
549
|
+
}) {
|
|
550
|
+
await ensureDir(path.dirname(queuePath));
|
|
551
|
+
let filesProcessed = 0;
|
|
552
|
+
let eventsAggregated = 0;
|
|
553
|
+
|
|
554
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
555
|
+
const files = Array.isArray(sessionFiles) ? sessionFiles : [];
|
|
556
|
+
const totalFiles = files.length;
|
|
557
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
558
|
+
const projectEnabled = typeof projectQueuePath === "string" && projectQueuePath.length > 0;
|
|
559
|
+
const projectState = projectEnabled ? normalizeProjectState(cursors?.projectHourly) : null;
|
|
560
|
+
const projectTouchedBuckets = projectEnabled ? new Set() : null;
|
|
561
|
+
const touchedBuckets = new Set();
|
|
562
|
+
const defaultSource = normalizeSourceInput(source) || "openclaw";
|
|
563
|
+
|
|
564
|
+
if (!cursors.files || typeof cursors.files !== "object") {
|
|
565
|
+
cursors.files = {};
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
for (let idx = 0; idx < files.length; idx++) {
|
|
569
|
+
const entry = files[idx];
|
|
570
|
+
const filePath = typeof entry === "string" ? entry : entry?.path;
|
|
571
|
+
if (!filePath) continue;
|
|
572
|
+
const fileSource =
|
|
573
|
+
typeof entry === "string"
|
|
574
|
+
? defaultSource
|
|
575
|
+
: normalizeSourceInput(entry?.source) || defaultSource;
|
|
576
|
+
const st = await fs.stat(filePath).catch(() => null);
|
|
577
|
+
if (!st || !st.isFile()) continue;
|
|
578
|
+
|
|
579
|
+
const key = filePath;
|
|
580
|
+
const prev = cursors.files[key] || null;
|
|
581
|
+
const inode = st.ino || 0;
|
|
582
|
+
const startOffset = prev && prev.inode === inode ? prev.offset || 0 : 0;
|
|
583
|
+
|
|
584
|
+
const result = await parseOpenclawSessionFile({
|
|
585
|
+
filePath,
|
|
586
|
+
startOffset,
|
|
587
|
+
hourlyState,
|
|
588
|
+
touchedBuckets,
|
|
589
|
+
source: fileSource,
|
|
590
|
+
projectState,
|
|
591
|
+
projectTouchedBuckets,
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
cursors.files[key] = {
|
|
595
|
+
inode,
|
|
596
|
+
offset: result.endOffset,
|
|
597
|
+
updatedAt: new Date().toISOString(),
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
filesProcessed += 1;
|
|
601
|
+
eventsAggregated += result.eventsAggregated;
|
|
602
|
+
|
|
603
|
+
if (cb) {
|
|
604
|
+
cb({
|
|
605
|
+
index: idx + 1,
|
|
606
|
+
total: totalFiles,
|
|
607
|
+
filePath,
|
|
608
|
+
filesProcessed,
|
|
609
|
+
eventsAggregated,
|
|
610
|
+
bucketsQueued: touchedBuckets.size,
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
616
|
+
const projectBucketsQueued = projectEnabled
|
|
617
|
+
? await enqueueTouchedProjectBuckets({ projectQueuePath, projectState, projectTouchedBuckets })
|
|
618
|
+
: 0;
|
|
619
|
+
hourlyState.updatedAt = new Date().toISOString();
|
|
620
|
+
cursors.hourly = hourlyState;
|
|
621
|
+
if (projectState) {
|
|
622
|
+
projectState.updatedAt = new Date().toISOString();
|
|
623
|
+
cursors.projectHourly = projectState;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
return { filesProcessed, eventsAggregated, bucketsQueued, projectBucketsQueued };
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
async function parseOpenclawSessionFile({
|
|
630
|
+
filePath,
|
|
631
|
+
startOffset,
|
|
632
|
+
hourlyState,
|
|
633
|
+
touchedBuckets,
|
|
634
|
+
source,
|
|
635
|
+
projectState,
|
|
636
|
+
projectTouchedBuckets,
|
|
637
|
+
}) {
|
|
638
|
+
const st = await fs.stat(filePath);
|
|
639
|
+
const endOffset = st.size;
|
|
640
|
+
if (startOffset >= endOffset) return { endOffset, eventsAggregated: 0 };
|
|
641
|
+
|
|
642
|
+
const stream = fssync.createReadStream(filePath, { encoding: "utf8", start: startOffset });
|
|
643
|
+
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
644
|
+
|
|
645
|
+
let eventsAggregated = 0;
|
|
646
|
+
for await (const line of rl) {
|
|
647
|
+
if (!line) continue;
|
|
648
|
+
// Fast-path filter: OpenClaw assistant messages include message.usage.totalTokens.
|
|
649
|
+
if (!line.includes('"usage"') || !line.includes("totalTokens")) continue;
|
|
650
|
+
|
|
651
|
+
let obj;
|
|
652
|
+
try {
|
|
653
|
+
obj = JSON.parse(line);
|
|
654
|
+
} catch (_e) {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (obj?.type !== "message") continue;
|
|
659
|
+
const msg = obj?.message;
|
|
660
|
+
if (!msg || typeof msg !== "object") continue;
|
|
661
|
+
|
|
662
|
+
const usage = msg.usage;
|
|
663
|
+
if (!usage || typeof usage !== "object") continue;
|
|
664
|
+
|
|
665
|
+
const tokenTimestamp = typeof obj?.timestamp === "string" ? obj.timestamp : null;
|
|
666
|
+
if (!tokenTimestamp) continue;
|
|
667
|
+
|
|
668
|
+
const model = normalizeModelInput(msg.model) || DEFAULT_MODEL;
|
|
669
|
+
|
|
670
|
+
const delta = {
|
|
671
|
+
input_tokens: Number(usage.input || 0),
|
|
672
|
+
cached_input_tokens: Number((usage.cacheRead || 0) + (usage.cacheWrite || 0)),
|
|
673
|
+
output_tokens: Number(usage.output || 0),
|
|
674
|
+
reasoning_output_tokens: 0,
|
|
675
|
+
total_tokens: Number(usage.totalTokens || 0),
|
|
676
|
+
conversation_count: 1,
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
if (isAllZeroUsage(delta)) continue;
|
|
680
|
+
|
|
681
|
+
const bucketStart = toUtcHalfHourStart(tokenTimestamp);
|
|
682
|
+
if (!bucketStart) continue;
|
|
683
|
+
|
|
684
|
+
const bucket = getHourlyBucket(hourlyState, source, model, bucketStart);
|
|
685
|
+
addTotals(bucket.totals, delta);
|
|
686
|
+
touchedBuckets.add(bucketKey(source, model, bucketStart));
|
|
687
|
+
|
|
688
|
+
// Project-level OpenClaw attribution is not supported yet (no stable cwd info).
|
|
689
|
+
// If OpenClaw later records cwd per event, we can mirror rollout's project logic.
|
|
690
|
+
eventsAggregated += 1;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
rl.close();
|
|
694
|
+
stream.close?.();
|
|
695
|
+
return { endOffset, eventsAggregated };
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
async function parseRolloutFile({
|
|
699
|
+
filePath,
|
|
700
|
+
startOffset,
|
|
701
|
+
lastTotal,
|
|
702
|
+
lastModel,
|
|
703
|
+
hourlyState,
|
|
704
|
+
touchedBuckets,
|
|
705
|
+
source,
|
|
706
|
+
projectState,
|
|
707
|
+
projectTouchedBuckets,
|
|
708
|
+
projectRef,
|
|
709
|
+
projectKey,
|
|
710
|
+
projectMetaCache,
|
|
711
|
+
publicRepoCache,
|
|
712
|
+
publicRepoResolver,
|
|
713
|
+
}) {
|
|
714
|
+
const st = await fs.stat(filePath);
|
|
715
|
+
const endOffset = st.size;
|
|
716
|
+
if (startOffset >= endOffset) {
|
|
717
|
+
return { endOffset, lastTotal, lastModel, eventsAggregated: 0 };
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const stream = fssync.createReadStream(filePath, { encoding: "utf8", start: startOffset });
|
|
721
|
+
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
722
|
+
|
|
723
|
+
let model = typeof lastModel === "string" ? lastModel : null;
|
|
724
|
+
let totals = lastTotal && typeof lastTotal === "object" ? lastTotal : null;
|
|
725
|
+
let currentCwd = null;
|
|
726
|
+
let currentProjectRef = projectRef || null;
|
|
727
|
+
let currentProjectKey = projectKey || null;
|
|
728
|
+
let eventsAggregated = 0;
|
|
729
|
+
|
|
730
|
+
for await (const line of rl) {
|
|
731
|
+
if (!line) continue;
|
|
732
|
+
const maybeTokenCount = line.includes('"token_count"');
|
|
733
|
+
const maybeTurnContext =
|
|
734
|
+
!maybeTokenCount &&
|
|
735
|
+
(line.includes('"turn_context"') || line.includes('"session_meta"')) &&
|
|
736
|
+
(line.includes('"model"') || line.includes('"cwd"'));
|
|
737
|
+
if (!maybeTokenCount && !maybeTurnContext) continue;
|
|
738
|
+
|
|
739
|
+
let obj;
|
|
740
|
+
try {
|
|
741
|
+
obj = JSON.parse(line);
|
|
742
|
+
} catch (_e) {
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (
|
|
747
|
+
(obj?.type === "turn_context" || obj?.type === "session_meta") &&
|
|
748
|
+
obj?.payload &&
|
|
749
|
+
typeof obj.payload === "object"
|
|
750
|
+
) {
|
|
751
|
+
if (typeof obj.payload.model === "string") {
|
|
752
|
+
model = obj.payload.model;
|
|
753
|
+
}
|
|
754
|
+
if (projectState && typeof obj.payload.cwd === "string") {
|
|
755
|
+
const nextCwd = obj.payload.cwd.trim();
|
|
756
|
+
if (nextCwd && nextCwd !== currentCwd) {
|
|
757
|
+
const context = await resolveProjectContextForPath({
|
|
758
|
+
startDir: nextCwd,
|
|
759
|
+
projectMetaCache,
|
|
760
|
+
publicRepoCache,
|
|
761
|
+
publicRepoResolver,
|
|
762
|
+
projectState,
|
|
763
|
+
});
|
|
764
|
+
currentCwd = nextCwd;
|
|
765
|
+
currentProjectRef = context?.projectRef || null;
|
|
766
|
+
currentProjectKey = context?.projectKey || null;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
const token = extractTokenCount(obj);
|
|
773
|
+
if (!token) continue;
|
|
774
|
+
|
|
775
|
+
const info = token.info;
|
|
776
|
+
if (!info || typeof info !== "object") continue;
|
|
777
|
+
|
|
778
|
+
const tokenTimestamp = typeof token.timestamp === "string" ? token.timestamp : null;
|
|
779
|
+
if (!tokenTimestamp) continue;
|
|
780
|
+
|
|
781
|
+
const lastUsage = info.last_token_usage;
|
|
782
|
+
const totalUsage = info.total_token_usage;
|
|
783
|
+
|
|
784
|
+
const delta = pickDelta(lastUsage, totalUsage, totals);
|
|
785
|
+
if (!delta) continue;
|
|
786
|
+
delta.conversation_count = 1;
|
|
787
|
+
|
|
788
|
+
if (totalUsage && typeof totalUsage === "object") {
|
|
789
|
+
totals = totalUsage;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
const bucketStart = toUtcHalfHourStart(tokenTimestamp);
|
|
793
|
+
if (!bucketStart) continue;
|
|
794
|
+
|
|
795
|
+
const bucket = getHourlyBucket(hourlyState, source, model, bucketStart);
|
|
796
|
+
addTotals(bucket.totals, delta);
|
|
797
|
+
touchedBuckets.add(bucketKey(source, model, bucketStart));
|
|
798
|
+
if (currentProjectKey && projectState && projectTouchedBuckets) {
|
|
799
|
+
const projectBucket = getProjectBucket(
|
|
800
|
+
projectState,
|
|
801
|
+
currentProjectKey,
|
|
802
|
+
source,
|
|
803
|
+
bucketStart,
|
|
804
|
+
currentProjectRef,
|
|
805
|
+
);
|
|
806
|
+
addTotals(projectBucket.totals, delta);
|
|
807
|
+
projectTouchedBuckets.add(projectBucketKey(currentProjectKey, source, bucketStart));
|
|
808
|
+
}
|
|
809
|
+
eventsAggregated += 1;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
return { endOffset, lastTotal: totals, lastModel: model, eventsAggregated };
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
async function parseClaudeFile({
|
|
816
|
+
filePath,
|
|
817
|
+
startOffset,
|
|
818
|
+
hourlyState,
|
|
819
|
+
touchedBuckets,
|
|
820
|
+
source,
|
|
821
|
+
projectState,
|
|
822
|
+
projectTouchedBuckets,
|
|
823
|
+
projectRef,
|
|
824
|
+
projectKey,
|
|
825
|
+
}) {
|
|
826
|
+
const st = await fs.stat(filePath).catch(() => null);
|
|
827
|
+
if (!st || !st.isFile()) return { endOffset: startOffset, eventsAggregated: 0 };
|
|
828
|
+
|
|
829
|
+
const endOffset = st.size;
|
|
830
|
+
if (startOffset >= endOffset) return { endOffset, eventsAggregated: 0 };
|
|
831
|
+
|
|
832
|
+
const stream = fssync.createReadStream(filePath, { encoding: "utf8", start: startOffset });
|
|
833
|
+
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
834
|
+
|
|
835
|
+
let eventsAggregated = 0;
|
|
836
|
+
for await (const line of rl) {
|
|
837
|
+
if (!line || !line.includes('\"usage\"')) continue;
|
|
838
|
+
let obj;
|
|
839
|
+
try {
|
|
840
|
+
obj = JSON.parse(line);
|
|
841
|
+
} catch (_e) {
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
const usage = obj?.message?.usage || obj?.usage;
|
|
846
|
+
if (!usage || typeof usage !== "object") continue;
|
|
847
|
+
|
|
848
|
+
const model = normalizeModelInput(obj?.message?.model || obj?.model) || DEFAULT_MODEL;
|
|
849
|
+
const tokenTimestamp = typeof obj?.timestamp === "string" ? obj.timestamp : null;
|
|
850
|
+
if (!tokenTimestamp) continue;
|
|
851
|
+
|
|
852
|
+
const delta = normalizeClaudeUsage(usage);
|
|
853
|
+
if (!delta || isAllZeroUsage(delta)) continue;
|
|
854
|
+
delta.conversation_count = 1;
|
|
855
|
+
|
|
856
|
+
const bucketStart = toUtcHalfHourStart(tokenTimestamp);
|
|
857
|
+
if (!bucketStart) continue;
|
|
858
|
+
|
|
859
|
+
const bucket = getHourlyBucket(hourlyState, source, model, bucketStart);
|
|
860
|
+
addTotals(bucket.totals, delta);
|
|
861
|
+
touchedBuckets.add(bucketKey(source, model, bucketStart));
|
|
862
|
+
if (projectKey && projectState && projectTouchedBuckets) {
|
|
863
|
+
const projectBucket = getProjectBucket(
|
|
864
|
+
projectState,
|
|
865
|
+
projectKey,
|
|
866
|
+
source,
|
|
867
|
+
bucketStart,
|
|
868
|
+
projectRef,
|
|
869
|
+
);
|
|
870
|
+
addTotals(projectBucket.totals, delta);
|
|
871
|
+
projectTouchedBuckets.add(projectBucketKey(projectKey, source, bucketStart));
|
|
872
|
+
}
|
|
873
|
+
eventsAggregated += 1;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
rl.close();
|
|
877
|
+
stream.close?.();
|
|
878
|
+
return { endOffset, eventsAggregated };
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
async function parseGeminiFile({
|
|
882
|
+
filePath,
|
|
883
|
+
startIndex,
|
|
884
|
+
lastTotals,
|
|
885
|
+
lastModel,
|
|
886
|
+
hourlyState,
|
|
887
|
+
touchedBuckets,
|
|
888
|
+
source,
|
|
889
|
+
projectState,
|
|
890
|
+
projectTouchedBuckets,
|
|
891
|
+
projectRef,
|
|
892
|
+
projectKey,
|
|
893
|
+
}) {
|
|
894
|
+
const raw = await fs.readFile(filePath, "utf8").catch(() => "");
|
|
895
|
+
if (!raw.trim()) return { lastIndex: startIndex, lastTotals, lastModel, eventsAggregated: 0 };
|
|
896
|
+
|
|
897
|
+
let session;
|
|
898
|
+
try {
|
|
899
|
+
session = JSON.parse(raw);
|
|
900
|
+
} catch (_e) {
|
|
901
|
+
return { lastIndex: startIndex, lastTotals, lastModel, eventsAggregated: 0 };
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const messages = Array.isArray(session?.messages) ? session.messages : [];
|
|
905
|
+
if (startIndex >= messages.length) {
|
|
906
|
+
startIndex = -1;
|
|
907
|
+
lastTotals = null;
|
|
908
|
+
lastModel = null;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
let eventsAggregated = 0;
|
|
912
|
+
let model = typeof lastModel === "string" ? lastModel : null;
|
|
913
|
+
let totals = lastTotals && typeof lastTotals === "object" ? lastTotals : null;
|
|
914
|
+
const begin = Number.isFinite(startIndex) ? startIndex + 1 : 0;
|
|
915
|
+
|
|
916
|
+
for (let idx = begin; idx < messages.length; idx++) {
|
|
917
|
+
const msg = messages[idx];
|
|
918
|
+
if (!msg || typeof msg !== "object") continue;
|
|
919
|
+
|
|
920
|
+
const normalizedModel = normalizeModelInput(msg.model);
|
|
921
|
+
if (normalizedModel) model = normalizedModel;
|
|
922
|
+
|
|
923
|
+
const timestamp = typeof msg.timestamp === "string" ? msg.timestamp : null;
|
|
924
|
+
const currentTotals = normalizeGeminiTokens(msg.tokens);
|
|
925
|
+
if (!timestamp || !currentTotals) {
|
|
926
|
+
totals = currentTotals || totals;
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
const delta = diffGeminiTotals(currentTotals, totals);
|
|
931
|
+
if (!delta || isAllZeroUsage(delta)) {
|
|
932
|
+
totals = currentTotals;
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
935
|
+
delta.conversation_count = 1;
|
|
936
|
+
|
|
937
|
+
const bucketStart = toUtcHalfHourStart(timestamp);
|
|
938
|
+
if (!bucketStart) {
|
|
939
|
+
totals = currentTotals;
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
const bucket = getHourlyBucket(hourlyState, source, model, bucketStart);
|
|
944
|
+
addTotals(bucket.totals, delta);
|
|
945
|
+
touchedBuckets.add(bucketKey(source, model, bucketStart));
|
|
946
|
+
if (projectKey && projectState && projectTouchedBuckets) {
|
|
947
|
+
const projectBucket = getProjectBucket(
|
|
948
|
+
projectState,
|
|
949
|
+
projectKey,
|
|
950
|
+
source,
|
|
951
|
+
bucketStart,
|
|
952
|
+
projectRef,
|
|
953
|
+
);
|
|
954
|
+
addTotals(projectBucket.totals, delta);
|
|
955
|
+
projectTouchedBuckets.add(projectBucketKey(projectKey, source, bucketStart));
|
|
956
|
+
}
|
|
957
|
+
eventsAggregated += 1;
|
|
958
|
+
totals = currentTotals;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
return {
|
|
962
|
+
lastIndex: messages.length - 1,
|
|
963
|
+
lastTotals: totals,
|
|
964
|
+
lastModel: model,
|
|
965
|
+
eventsAggregated,
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
async function parseOpencodeMessageFile({
|
|
970
|
+
filePath,
|
|
971
|
+
messageIndex,
|
|
972
|
+
fallbackTotals,
|
|
973
|
+
fallbackMessageKey,
|
|
974
|
+
hourlyState,
|
|
975
|
+
touchedBuckets,
|
|
976
|
+
source,
|
|
977
|
+
projectState,
|
|
978
|
+
projectTouchedBuckets,
|
|
979
|
+
projectRef,
|
|
980
|
+
projectKey,
|
|
981
|
+
}) {
|
|
982
|
+
const fallbackKey =
|
|
983
|
+
typeof fallbackMessageKey === "string" && fallbackMessageKey.trim()
|
|
984
|
+
? fallbackMessageKey.trim()
|
|
985
|
+
: null;
|
|
986
|
+
const legacyTotals = fallbackTotals && typeof fallbackTotals === "object" ? fallbackTotals : null;
|
|
987
|
+
const fallbackEntry = messageIndex && fallbackKey ? messageIndex[fallbackKey] : null;
|
|
988
|
+
const fallbackLastTotals =
|
|
989
|
+
fallbackEntry && typeof fallbackEntry.lastTotals === "object"
|
|
990
|
+
? fallbackEntry.lastTotals
|
|
991
|
+
: legacyTotals;
|
|
992
|
+
|
|
993
|
+
const raw = await fs.readFile(filePath, "utf8").catch(() => "");
|
|
994
|
+
if (!raw.trim()) {
|
|
995
|
+
return {
|
|
996
|
+
messageKey: fallbackKey,
|
|
997
|
+
lastTotals: fallbackLastTotals,
|
|
998
|
+
eventsAggregated: 0,
|
|
999
|
+
shouldUpdate: false,
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
let msg;
|
|
1004
|
+
try {
|
|
1005
|
+
msg = JSON.parse(raw);
|
|
1006
|
+
} catch (_e) {
|
|
1007
|
+
return {
|
|
1008
|
+
messageKey: fallbackKey,
|
|
1009
|
+
lastTotals: fallbackLastTotals,
|
|
1010
|
+
eventsAggregated: 0,
|
|
1011
|
+
shouldUpdate: false,
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
const messageKey = deriveOpencodeMessageKey(msg, filePath);
|
|
1016
|
+
const prev = messageIndex && messageKey ? messageIndex[messageKey] : null;
|
|
1017
|
+
const indexTotals = prev && typeof prev.lastTotals === "object" ? prev.lastTotals : null;
|
|
1018
|
+
const fallbackMatch = !fallbackKey || fallbackKey === messageKey;
|
|
1019
|
+
const lastTotals = indexTotals || (fallbackMatch ? fallbackLastTotals : null);
|
|
1020
|
+
|
|
1021
|
+
const currentTotals = normalizeOpencodeTokens(msg?.tokens);
|
|
1022
|
+
if (!currentTotals) {
|
|
1023
|
+
return { messageKey, lastTotals, eventsAggregated: 0, shouldUpdate: false };
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
const delta = diffGeminiTotals(currentTotals, lastTotals);
|
|
1027
|
+
if (!delta || isAllZeroUsage(delta)) {
|
|
1028
|
+
return { messageKey, lastTotals: currentTotals, eventsAggregated: 0, shouldUpdate: true };
|
|
1029
|
+
}
|
|
1030
|
+
delta.conversation_count = 1;
|
|
1031
|
+
|
|
1032
|
+
const timestampMs = coerceEpochMs(msg?.time?.completed) || coerceEpochMs(msg?.time?.created);
|
|
1033
|
+
if (!timestampMs) {
|
|
1034
|
+
return {
|
|
1035
|
+
messageKey,
|
|
1036
|
+
lastTotals,
|
|
1037
|
+
eventsAggregated: 0,
|
|
1038
|
+
shouldUpdate: Boolean(lastTotals),
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
const tsIso = new Date(timestampMs).toISOString();
|
|
1043
|
+
const bucketStart = toUtcHalfHourStart(tsIso);
|
|
1044
|
+
if (!bucketStart) {
|
|
1045
|
+
return {
|
|
1046
|
+
messageKey,
|
|
1047
|
+
lastTotals,
|
|
1048
|
+
eventsAggregated: 0,
|
|
1049
|
+
shouldUpdate: Boolean(lastTotals),
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
const model = normalizeModelInput(msg?.modelID || msg?.model || msg?.modelId) || DEFAULT_MODEL;
|
|
1054
|
+
const bucket = getHourlyBucket(hourlyState, source, model, bucketStart);
|
|
1055
|
+
addTotals(bucket.totals, delta);
|
|
1056
|
+
touchedBuckets.add(bucketKey(source, model, bucketStart));
|
|
1057
|
+
if (projectKey && projectState && projectTouchedBuckets) {
|
|
1058
|
+
const projectBucket = getProjectBucket(
|
|
1059
|
+
projectState,
|
|
1060
|
+
projectKey,
|
|
1061
|
+
source,
|
|
1062
|
+
bucketStart,
|
|
1063
|
+
projectRef,
|
|
1064
|
+
);
|
|
1065
|
+
addTotals(projectBucket.totals, delta);
|
|
1066
|
+
projectTouchedBuckets.add(projectBucketKey(projectKey, source, bucketStart));
|
|
1067
|
+
}
|
|
1068
|
+
return { messageKey, lastTotals: currentTotals, eventsAggregated: 1, shouldUpdate: true };
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
async function enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets }) {
|
|
1072
|
+
if (!touchedBuckets || touchedBuckets.size === 0) return 0;
|
|
1073
|
+
|
|
1074
|
+
const touchedGroups = new Set();
|
|
1075
|
+
for (const bucketStart of touchedBuckets) {
|
|
1076
|
+
const parsed = parseBucketKey(bucketStart);
|
|
1077
|
+
const hourStart = parsed.hourStart;
|
|
1078
|
+
if (!hourStart) continue;
|
|
1079
|
+
touchedGroups.add(groupBucketKey(parsed.source, hourStart));
|
|
1080
|
+
}
|
|
1081
|
+
if (touchedGroups.size === 0) return 0;
|
|
1082
|
+
|
|
1083
|
+
const groupQueued =
|
|
1084
|
+
hourlyState.groupQueued && typeof hourlyState.groupQueued === "object"
|
|
1085
|
+
? hourlyState.groupQueued
|
|
1086
|
+
: {};
|
|
1087
|
+
let codexTouched = false;
|
|
1088
|
+
const legacyGroups = new Set();
|
|
1089
|
+
for (const groupKey of touchedGroups) {
|
|
1090
|
+
if (Object.prototype.hasOwnProperty.call(groupQueued, groupKey)) {
|
|
1091
|
+
legacyGroups.add(groupKey);
|
|
1092
|
+
}
|
|
1093
|
+
if (!codexTouched && groupKey.startsWith(`${DEFAULT_SOURCE}${BUCKET_SEPARATOR}`)) {
|
|
1094
|
+
codexTouched = true;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
const groupedBuckets = new Map();
|
|
1099
|
+
for (const [key, bucket] of Object.entries(hourlyState.buckets || {})) {
|
|
1100
|
+
if (!bucket || !bucket.totals) continue;
|
|
1101
|
+
const parsed = parseBucketKey(key);
|
|
1102
|
+
const hourStart = parsed.hourStart;
|
|
1103
|
+
if (!hourStart) continue;
|
|
1104
|
+
const groupKey = groupBucketKey(parsed.source, hourStart);
|
|
1105
|
+
if (!touchedGroups.has(groupKey) || legacyGroups.has(groupKey)) continue;
|
|
1106
|
+
|
|
1107
|
+
const source = normalizeSourceInput(parsed.source) || DEFAULT_SOURCE;
|
|
1108
|
+
const model = normalizeModelInput(parsed.model) || DEFAULT_MODEL;
|
|
1109
|
+
let group = groupedBuckets.get(groupKey);
|
|
1110
|
+
if (!group) {
|
|
1111
|
+
group = { source, hourStart, buckets: new Map() };
|
|
1112
|
+
groupedBuckets.set(groupKey, group);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
if (bucket.queuedKey != null && typeof bucket.queuedKey !== "string") {
|
|
1116
|
+
bucket.queuedKey = null;
|
|
1117
|
+
}
|
|
1118
|
+
group.buckets.set(model, bucket);
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
if (codexTouched) {
|
|
1122
|
+
const recomputeGroups = new Set();
|
|
1123
|
+
for (const [key, bucket] of Object.entries(hourlyState.buckets || {})) {
|
|
1124
|
+
if (!bucket || !bucket.totals) continue;
|
|
1125
|
+
const parsed = parseBucketKey(key);
|
|
1126
|
+
const hourStart = parsed.hourStart;
|
|
1127
|
+
if (!hourStart) continue;
|
|
1128
|
+
const source = normalizeSourceInput(parsed.source) || DEFAULT_SOURCE;
|
|
1129
|
+
if (source !== "every-code") continue;
|
|
1130
|
+
const groupKey = groupBucketKey(source, hourStart);
|
|
1131
|
+
if (legacyGroups.has(groupKey) || groupedBuckets.has(groupKey)) continue;
|
|
1132
|
+
const model = normalizeModelInput(parsed.model) || DEFAULT_MODEL;
|
|
1133
|
+
if (model !== DEFAULT_MODEL) continue;
|
|
1134
|
+
recomputeGroups.add(groupKey);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
if (recomputeGroups.size > 0) {
|
|
1138
|
+
for (const [key, bucket] of Object.entries(hourlyState.buckets || {})) {
|
|
1139
|
+
if (!bucket || !bucket.totals) continue;
|
|
1140
|
+
const parsed = parseBucketKey(key);
|
|
1141
|
+
const hourStart = parsed.hourStart;
|
|
1142
|
+
if (!hourStart) continue;
|
|
1143
|
+
const source = normalizeSourceInput(parsed.source) || DEFAULT_SOURCE;
|
|
1144
|
+
const groupKey = groupBucketKey(source, hourStart);
|
|
1145
|
+
if (!recomputeGroups.has(groupKey)) continue;
|
|
1146
|
+
let group = groupedBuckets.get(groupKey);
|
|
1147
|
+
if (!group) {
|
|
1148
|
+
group = { source, hourStart, buckets: new Map() };
|
|
1149
|
+
groupedBuckets.set(groupKey, group);
|
|
1150
|
+
}
|
|
1151
|
+
if (bucket.queuedKey != null && typeof bucket.queuedKey !== "string") {
|
|
1152
|
+
bucket.queuedKey = null;
|
|
1153
|
+
}
|
|
1154
|
+
const model = normalizeModelInput(parsed.model) || DEFAULT_MODEL;
|
|
1155
|
+
group.buckets.set(model, bucket);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
const codexDominants = collectCodexDominantModels(hourlyState);
|
|
1161
|
+
|
|
1162
|
+
const toAppend = [];
|
|
1163
|
+
for (const group of groupedBuckets.values()) {
|
|
1164
|
+
const unknownBucket = group.buckets.get(DEFAULT_MODEL) || null;
|
|
1165
|
+
const dominantModel = pickDominantModel(group.buckets);
|
|
1166
|
+
let alignedModel = null;
|
|
1167
|
+
if (unknownBucket?.alignedModel) {
|
|
1168
|
+
const normalized = normalizeModelInput(unknownBucket.alignedModel);
|
|
1169
|
+
alignedModel = normalized && normalized !== DEFAULT_MODEL ? normalized : null;
|
|
1170
|
+
}
|
|
1171
|
+
const zeroTotals = initTotals();
|
|
1172
|
+
const zeroKey = totalsKey(zeroTotals);
|
|
1173
|
+
|
|
1174
|
+
if (dominantModel) {
|
|
1175
|
+
if (alignedModel && !group.buckets.has(alignedModel)) {
|
|
1176
|
+
toAppend.push(
|
|
1177
|
+
JSON.stringify({
|
|
1178
|
+
source: group.source,
|
|
1179
|
+
model: alignedModel,
|
|
1180
|
+
hour_start: group.hourStart,
|
|
1181
|
+
input_tokens: zeroTotals.input_tokens,
|
|
1182
|
+
cached_input_tokens: zeroTotals.cached_input_tokens,
|
|
1183
|
+
output_tokens: zeroTotals.output_tokens,
|
|
1184
|
+
reasoning_output_tokens: zeroTotals.reasoning_output_tokens,
|
|
1185
|
+
total_tokens: zeroTotals.total_tokens,
|
|
1186
|
+
conversation_count: zeroTotals.conversation_count,
|
|
1187
|
+
}),
|
|
1188
|
+
);
|
|
1189
|
+
}
|
|
1190
|
+
if (
|
|
1191
|
+
unknownBucket &&
|
|
1192
|
+
!alignedModel &&
|
|
1193
|
+
unknownBucket.queuedKey &&
|
|
1194
|
+
unknownBucket.queuedKey !== zeroKey
|
|
1195
|
+
) {
|
|
1196
|
+
if (unknownBucket.retractedUnknownKey !== zeroKey) {
|
|
1197
|
+
toAppend.push(
|
|
1198
|
+
JSON.stringify({
|
|
1199
|
+
source: group.source,
|
|
1200
|
+
model: DEFAULT_MODEL,
|
|
1201
|
+
hour_start: group.hourStart,
|
|
1202
|
+
input_tokens: zeroTotals.input_tokens,
|
|
1203
|
+
cached_input_tokens: zeroTotals.cached_input_tokens,
|
|
1204
|
+
output_tokens: zeroTotals.output_tokens,
|
|
1205
|
+
reasoning_output_tokens: zeroTotals.reasoning_output_tokens,
|
|
1206
|
+
total_tokens: zeroTotals.total_tokens,
|
|
1207
|
+
conversation_count: zeroTotals.conversation_count,
|
|
1208
|
+
}),
|
|
1209
|
+
);
|
|
1210
|
+
unknownBucket.retractedUnknownKey = zeroKey;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
if (unknownBucket) unknownBucket.alignedModel = null;
|
|
1214
|
+
for (const [model, bucket] of group.buckets.entries()) {
|
|
1215
|
+
if (model === DEFAULT_MODEL) continue;
|
|
1216
|
+
let totals = bucket.totals;
|
|
1217
|
+
if (model === dominantModel && unknownBucket?.totals) {
|
|
1218
|
+
totals = cloneTotals(bucket.totals);
|
|
1219
|
+
addTotals(totals, unknownBucket.totals);
|
|
1220
|
+
}
|
|
1221
|
+
const key = totalsKey(totals);
|
|
1222
|
+
if (bucket.queuedKey === key) continue;
|
|
1223
|
+
toAppend.push(
|
|
1224
|
+
JSON.stringify({
|
|
1225
|
+
source: group.source,
|
|
1226
|
+
model,
|
|
1227
|
+
hour_start: group.hourStart,
|
|
1228
|
+
input_tokens: totals.input_tokens,
|
|
1229
|
+
cached_input_tokens: totals.cached_input_tokens,
|
|
1230
|
+
output_tokens: totals.output_tokens,
|
|
1231
|
+
reasoning_output_tokens: totals.reasoning_output_tokens,
|
|
1232
|
+
total_tokens: totals.total_tokens,
|
|
1233
|
+
conversation_count: totals.conversation_count,
|
|
1234
|
+
}),
|
|
1235
|
+
);
|
|
1236
|
+
bucket.queuedKey = key;
|
|
1237
|
+
}
|
|
1238
|
+
continue;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
if (!unknownBucket?.totals) continue;
|
|
1242
|
+
let outputModel = DEFAULT_MODEL;
|
|
1243
|
+
if (group.source === "every-code") {
|
|
1244
|
+
const aligned = findNearestCodexModel(group.hourStart, codexDominants);
|
|
1245
|
+
if (aligned) outputModel = aligned;
|
|
1246
|
+
}
|
|
1247
|
+
const nextAligned = outputModel !== DEFAULT_MODEL ? outputModel : null;
|
|
1248
|
+
if (alignedModel && alignedModel !== nextAligned) {
|
|
1249
|
+
toAppend.push(
|
|
1250
|
+
JSON.stringify({
|
|
1251
|
+
source: group.source,
|
|
1252
|
+
model: alignedModel,
|
|
1253
|
+
hour_start: group.hourStart,
|
|
1254
|
+
input_tokens: zeroTotals.input_tokens,
|
|
1255
|
+
cached_input_tokens: zeroTotals.cached_input_tokens,
|
|
1256
|
+
output_tokens: zeroTotals.output_tokens,
|
|
1257
|
+
reasoning_output_tokens: zeroTotals.reasoning_output_tokens,
|
|
1258
|
+
total_tokens: zeroTotals.total_tokens,
|
|
1259
|
+
conversation_count: zeroTotals.conversation_count,
|
|
1260
|
+
}),
|
|
1261
|
+
);
|
|
1262
|
+
}
|
|
1263
|
+
if (
|
|
1264
|
+
!alignedModel &&
|
|
1265
|
+
nextAligned &&
|
|
1266
|
+
unknownBucket.queuedKey &&
|
|
1267
|
+
unknownBucket.queuedKey !== zeroKey
|
|
1268
|
+
) {
|
|
1269
|
+
if (unknownBucket.retractedUnknownKey !== zeroKey) {
|
|
1270
|
+
toAppend.push(
|
|
1271
|
+
JSON.stringify({
|
|
1272
|
+
source: group.source,
|
|
1273
|
+
model: DEFAULT_MODEL,
|
|
1274
|
+
hour_start: group.hourStart,
|
|
1275
|
+
input_tokens: zeroTotals.input_tokens,
|
|
1276
|
+
cached_input_tokens: zeroTotals.cached_input_tokens,
|
|
1277
|
+
output_tokens: zeroTotals.output_tokens,
|
|
1278
|
+
reasoning_output_tokens: zeroTotals.reasoning_output_tokens,
|
|
1279
|
+
total_tokens: zeroTotals.total_tokens,
|
|
1280
|
+
conversation_count: zeroTotals.conversation_count,
|
|
1281
|
+
}),
|
|
1282
|
+
);
|
|
1283
|
+
unknownBucket.retractedUnknownKey = zeroKey;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
if (unknownBucket) unknownBucket.alignedModel = nextAligned;
|
|
1287
|
+
const key = totalsKey(unknownBucket.totals);
|
|
1288
|
+
const outputKey = outputModel === DEFAULT_MODEL ? key : `${key}|${outputModel}`;
|
|
1289
|
+
if (unknownBucket.queuedKey === outputKey) continue;
|
|
1290
|
+
toAppend.push(
|
|
1291
|
+
JSON.stringify({
|
|
1292
|
+
source: group.source,
|
|
1293
|
+
model: outputModel,
|
|
1294
|
+
hour_start: group.hourStart,
|
|
1295
|
+
input_tokens: unknownBucket.totals.input_tokens,
|
|
1296
|
+
cached_input_tokens: unknownBucket.totals.cached_input_tokens,
|
|
1297
|
+
output_tokens: unknownBucket.totals.output_tokens,
|
|
1298
|
+
reasoning_output_tokens: unknownBucket.totals.reasoning_output_tokens,
|
|
1299
|
+
total_tokens: unknownBucket.totals.total_tokens,
|
|
1300
|
+
conversation_count: unknownBucket.totals.conversation_count,
|
|
1301
|
+
}),
|
|
1302
|
+
);
|
|
1303
|
+
unknownBucket.queuedKey = outputKey;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
if (legacyGroups.size > 0) {
|
|
1307
|
+
const grouped = new Map();
|
|
1308
|
+
for (const [key, bucket] of Object.entries(hourlyState.buckets || {})) {
|
|
1309
|
+
if (!bucket || !bucket.totals) continue;
|
|
1310
|
+
const parsed = parseBucketKey(key);
|
|
1311
|
+
const hourStart = parsed.hourStart;
|
|
1312
|
+
if (!hourStart) continue;
|
|
1313
|
+
const groupKey = groupBucketKey(parsed.source, hourStart);
|
|
1314
|
+
if (!legacyGroups.has(groupKey)) continue;
|
|
1315
|
+
|
|
1316
|
+
let group = grouped.get(groupKey);
|
|
1317
|
+
if (!group) {
|
|
1318
|
+
group = {
|
|
1319
|
+
source: normalizeSourceInput(parsed.source) || DEFAULT_SOURCE,
|
|
1320
|
+
hourStart,
|
|
1321
|
+
models: new Set(),
|
|
1322
|
+
totals: initTotals(),
|
|
1323
|
+
};
|
|
1324
|
+
grouped.set(groupKey, group);
|
|
1325
|
+
}
|
|
1326
|
+
group.models.add(parsed.model || DEFAULT_MODEL);
|
|
1327
|
+
addTotals(group.totals, bucket.totals);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
for (const group of grouped.values()) {
|
|
1331
|
+
const model = group.models.size === 1 ? [...group.models][0] : DEFAULT_MODEL;
|
|
1332
|
+
const key = totalsKey(group.totals);
|
|
1333
|
+
const groupKey = groupBucketKey(group.source, group.hourStart);
|
|
1334
|
+
if (groupQueued[groupKey] === key) continue;
|
|
1335
|
+
toAppend.push(
|
|
1336
|
+
JSON.stringify({
|
|
1337
|
+
source: group.source,
|
|
1338
|
+
model,
|
|
1339
|
+
hour_start: group.hourStart,
|
|
1340
|
+
input_tokens: group.totals.input_tokens,
|
|
1341
|
+
cached_input_tokens: group.totals.cached_input_tokens,
|
|
1342
|
+
output_tokens: group.totals.output_tokens,
|
|
1343
|
+
reasoning_output_tokens: group.totals.reasoning_output_tokens,
|
|
1344
|
+
total_tokens: group.totals.total_tokens,
|
|
1345
|
+
conversation_count: group.totals.conversation_count,
|
|
1346
|
+
}),
|
|
1347
|
+
);
|
|
1348
|
+
groupQueued[groupKey] = key;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
hourlyState.groupQueued = groupQueued;
|
|
1353
|
+
|
|
1354
|
+
if (toAppend.length > 0) {
|
|
1355
|
+
await fs.appendFile(queuePath, toAppend.join("\n") + "\n", "utf8");
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
return toAppend.length;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
async function enqueueTouchedProjectBuckets({
|
|
1362
|
+
projectQueuePath,
|
|
1363
|
+
projectState,
|
|
1364
|
+
projectTouchedBuckets,
|
|
1365
|
+
}) {
|
|
1366
|
+
if (
|
|
1367
|
+
!projectQueuePath ||
|
|
1368
|
+
!projectState ||
|
|
1369
|
+
!projectTouchedBuckets ||
|
|
1370
|
+
projectTouchedBuckets.size === 0
|
|
1371
|
+
)
|
|
1372
|
+
return 0;
|
|
1373
|
+
|
|
1374
|
+
await ensureDir(path.dirname(projectQueuePath));
|
|
1375
|
+
|
|
1376
|
+
const toAppend = [];
|
|
1377
|
+
for (const key of projectTouchedBuckets) {
|
|
1378
|
+
const bucket = projectState.buckets[key];
|
|
1379
|
+
if (!bucket || !bucket.totals) continue;
|
|
1380
|
+
const totals = bucket.totals;
|
|
1381
|
+
const queuedKey = totalsKey(totals);
|
|
1382
|
+
if (bucket.queuedKey === queuedKey) continue;
|
|
1383
|
+
const projectRef = typeof bucket.project_ref === "string" ? bucket.project_ref : null;
|
|
1384
|
+
const projectKey = typeof bucket.project_key === "string" ? bucket.project_key : null;
|
|
1385
|
+
if (!projectRef || !projectKey) continue;
|
|
1386
|
+
|
|
1387
|
+
toAppend.push(
|
|
1388
|
+
JSON.stringify({
|
|
1389
|
+
project_ref: projectRef,
|
|
1390
|
+
project_key: projectKey,
|
|
1391
|
+
source: bucket.source,
|
|
1392
|
+
hour_start: bucket.hour_start,
|
|
1393
|
+
input_tokens: totals.input_tokens,
|
|
1394
|
+
cached_input_tokens: totals.cached_input_tokens,
|
|
1395
|
+
output_tokens: totals.output_tokens,
|
|
1396
|
+
reasoning_output_tokens: totals.reasoning_output_tokens,
|
|
1397
|
+
total_tokens: totals.total_tokens,
|
|
1398
|
+
conversation_count: totals.conversation_count,
|
|
1399
|
+
}),
|
|
1400
|
+
);
|
|
1401
|
+
bucket.queuedKey = queuedKey;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
if (toAppend.length > 0) {
|
|
1405
|
+
await fs.appendFile(projectQueuePath, toAppend.join("\n") + "\n", "utf8");
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
return toAppend.length;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
function pickDominantModel(buckets) {
|
|
1412
|
+
let dominantModel = null;
|
|
1413
|
+
let dominantTotal = -1;
|
|
1414
|
+
for (const [model, bucket] of buckets.entries()) {
|
|
1415
|
+
if (model === DEFAULT_MODEL) continue;
|
|
1416
|
+
const total = Number(bucket?.totals?.total_tokens || 0);
|
|
1417
|
+
if (
|
|
1418
|
+
dominantModel == null ||
|
|
1419
|
+
total > dominantTotal ||
|
|
1420
|
+
(total === dominantTotal && model < dominantModel)
|
|
1421
|
+
) {
|
|
1422
|
+
dominantModel = model;
|
|
1423
|
+
dominantTotal = total;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return dominantModel;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
function cloneTotals(totals) {
|
|
1430
|
+
const cloned = initTotals();
|
|
1431
|
+
addTotals(cloned, totals || {});
|
|
1432
|
+
return cloned;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
function collectCodexDominantModels(hourlyState) {
|
|
1436
|
+
const grouped = new Map();
|
|
1437
|
+
for (const [key, bucket] of Object.entries(hourlyState.buckets || {})) {
|
|
1438
|
+
if (!bucket || !bucket.totals) continue;
|
|
1439
|
+
const parsed = parseBucketKey(key);
|
|
1440
|
+
const hourStart = parsed.hourStart;
|
|
1441
|
+
if (!hourStart) continue;
|
|
1442
|
+
const source = normalizeSourceInput(parsed.source) || DEFAULT_SOURCE;
|
|
1443
|
+
if (source !== DEFAULT_SOURCE) continue;
|
|
1444
|
+
const model = normalizeModelInput(parsed.model) || DEFAULT_MODEL;
|
|
1445
|
+
if (model === DEFAULT_MODEL) continue;
|
|
1446
|
+
|
|
1447
|
+
let models = grouped.get(hourStart);
|
|
1448
|
+
if (!models) {
|
|
1449
|
+
models = new Map();
|
|
1450
|
+
grouped.set(hourStart, models);
|
|
1451
|
+
}
|
|
1452
|
+
const total = Number(bucket.totals.total_tokens || 0);
|
|
1453
|
+
models.set(model, (models.get(model) || 0) + total);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
const dominants = [];
|
|
1457
|
+
for (const [hourStart, models] of grouped.entries()) {
|
|
1458
|
+
let dominantModel = null;
|
|
1459
|
+
let dominantTotal = -1;
|
|
1460
|
+
for (const [model, total] of models.entries()) {
|
|
1461
|
+
if (
|
|
1462
|
+
dominantModel == null ||
|
|
1463
|
+
total > dominantTotal ||
|
|
1464
|
+
(total === dominantTotal && model < dominantModel)
|
|
1465
|
+
) {
|
|
1466
|
+
dominantModel = model;
|
|
1467
|
+
dominantTotal = total;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
if (dominantModel) {
|
|
1471
|
+
dominants.push({ hourStart, model: dominantModel });
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
return dominants;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
function findNearestCodexModel(hourStart, dominants) {
|
|
1479
|
+
if (!hourStart || !dominants || dominants.length === 0) return null;
|
|
1480
|
+
const target = Date.parse(hourStart);
|
|
1481
|
+
if (!Number.isFinite(target)) return null;
|
|
1482
|
+
|
|
1483
|
+
let best = null;
|
|
1484
|
+
for (const entry of dominants) {
|
|
1485
|
+
const candidate = Date.parse(entry.hourStart);
|
|
1486
|
+
if (!Number.isFinite(candidate)) continue;
|
|
1487
|
+
const diff = Math.abs(candidate - target);
|
|
1488
|
+
if (!best || diff < best.diff || (diff === best.diff && candidate < best.time)) {
|
|
1489
|
+
best = { diff, time: candidate, model: entry.model };
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
return best ? best.model : null;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
function normalizeHourlyState(raw) {
|
|
1497
|
+
const state = raw && typeof raw === "object" ? raw : {};
|
|
1498
|
+
const version = Number(state.version || 1);
|
|
1499
|
+
const rawBuckets = state.buckets && typeof state.buckets === "object" ? state.buckets : {};
|
|
1500
|
+
const buckets = {};
|
|
1501
|
+
const groupQueued = {};
|
|
1502
|
+
|
|
1503
|
+
if (!Number.isFinite(version) || version < 2) {
|
|
1504
|
+
for (const [key, value] of Object.entries(rawBuckets)) {
|
|
1505
|
+
const parsed = parseBucketKey(key);
|
|
1506
|
+
const hourStart = parsed.hourStart;
|
|
1507
|
+
if (!hourStart) continue;
|
|
1508
|
+
const source = normalizeSourceInput(parsed.source) || DEFAULT_SOURCE;
|
|
1509
|
+
const normalizedKey = bucketKey(source, DEFAULT_MODEL, hourStart);
|
|
1510
|
+
buckets[normalizedKey] = value;
|
|
1511
|
+
if (value?.queuedKey) {
|
|
1512
|
+
groupQueued[groupBucketKey(source, hourStart)] = value.queuedKey;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return {
|
|
1516
|
+
version: 3,
|
|
1517
|
+
buckets,
|
|
1518
|
+
groupQueued,
|
|
1519
|
+
updatedAt: typeof state.updatedAt === "string" ? state.updatedAt : null,
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
for (const [key, value] of Object.entries(rawBuckets)) {
|
|
1524
|
+
const parsed = parseBucketKey(key);
|
|
1525
|
+
const hourStart = parsed.hourStart;
|
|
1526
|
+
if (!hourStart) continue;
|
|
1527
|
+
const normalizedKey = bucketKey(parsed.source, parsed.model, hourStart);
|
|
1528
|
+
buckets[normalizedKey] = value;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
const existingGroupQueued =
|
|
1532
|
+
state.groupQueued && typeof state.groupQueued === "object" ? state.groupQueued : {};
|
|
1533
|
+
|
|
1534
|
+
return {
|
|
1535
|
+
version: 3,
|
|
1536
|
+
buckets,
|
|
1537
|
+
groupQueued: version >= 3 ? existingGroupQueued : {},
|
|
1538
|
+
updatedAt: typeof state.updatedAt === "string" ? state.updatedAt : null,
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
function normalizeProjectState(raw) {
|
|
1543
|
+
const state = raw && typeof raw === "object" ? raw : {};
|
|
1544
|
+
const rawBuckets = state.buckets && typeof state.buckets === "object" ? state.buckets : {};
|
|
1545
|
+
const buckets = {};
|
|
1546
|
+
const rawProjects = state.projects && typeof state.projects === "object" ? state.projects : {};
|
|
1547
|
+
const projects = {};
|
|
1548
|
+
|
|
1549
|
+
for (const [key, value] of Object.entries(rawBuckets)) {
|
|
1550
|
+
if (!key) continue;
|
|
1551
|
+
buckets[key] = value;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
for (const [key, value] of Object.entries(rawProjects)) {
|
|
1555
|
+
if (!key || !value || typeof value !== "object") continue;
|
|
1556
|
+
projects[key] = { ...value };
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
return {
|
|
1560
|
+
version: 2,
|
|
1561
|
+
buckets,
|
|
1562
|
+
projects,
|
|
1563
|
+
updatedAt: typeof state.updatedAt === "string" ? state.updatedAt : null,
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
function normalizeOpencodeState(raw) {
|
|
1568
|
+
const state = raw && typeof raw === "object" ? raw : {};
|
|
1569
|
+
const messages = state.messages && typeof state.messages === "object" ? state.messages : {};
|
|
1570
|
+
return {
|
|
1571
|
+
messages,
|
|
1572
|
+
updatedAt: typeof state.updatedAt === "string" ? state.updatedAt : null,
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
function normalizeMessageKeyPart(value) {
|
|
1577
|
+
if (typeof value !== "string") return "";
|
|
1578
|
+
return value.trim();
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
function deriveOpencodeMessageKey(msg, fallback) {
|
|
1582
|
+
const sessionId = normalizeMessageKeyPart(msg?.sessionID || msg?.sessionId || msg?.session_id);
|
|
1583
|
+
const messageId = normalizeMessageKeyPart(msg?.id || msg?.messageID || msg?.messageId);
|
|
1584
|
+
if (sessionId && messageId) return `${sessionId}|${messageId}`;
|
|
1585
|
+
return fallback;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
function getHourlyBucket(state, source, model, hourStart) {
|
|
1589
|
+
const buckets = state.buckets;
|
|
1590
|
+
const normalizedSource = normalizeSourceInput(source) || DEFAULT_SOURCE;
|
|
1591
|
+
const normalizedModel = normalizeModelInput(model) || DEFAULT_MODEL;
|
|
1592
|
+
const key = bucketKey(normalizedSource, normalizedModel, hourStart);
|
|
1593
|
+
let bucket = buckets[key];
|
|
1594
|
+
if (!bucket || typeof bucket !== "object") {
|
|
1595
|
+
bucket = { totals: initTotals(), queuedKey: null };
|
|
1596
|
+
buckets[key] = bucket;
|
|
1597
|
+
return bucket;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
if (!bucket.totals || typeof bucket.totals !== "object") {
|
|
1601
|
+
bucket.totals = initTotals();
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
if (bucket.queuedKey != null && typeof bucket.queuedKey !== "string") {
|
|
1605
|
+
bucket.queuedKey = null;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
return bucket;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
function getProjectBucket(state, projectKey, source, hourStart, projectRef) {
|
|
1612
|
+
const buckets = state.buckets;
|
|
1613
|
+
const normalizedSource = normalizeSourceInput(source) || DEFAULT_SOURCE;
|
|
1614
|
+
const key = projectBucketKey(projectKey, normalizedSource, hourStart);
|
|
1615
|
+
let bucket = buckets[key];
|
|
1616
|
+
if (!bucket || typeof bucket !== "object") {
|
|
1617
|
+
bucket = {
|
|
1618
|
+
totals: initTotals(),
|
|
1619
|
+
queuedKey: null,
|
|
1620
|
+
project_key: projectKey,
|
|
1621
|
+
project_ref: projectRef,
|
|
1622
|
+
source: normalizedSource,
|
|
1623
|
+
hour_start: hourStart,
|
|
1624
|
+
};
|
|
1625
|
+
buckets[key] = bucket;
|
|
1626
|
+
return bucket;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
if (!bucket.totals || typeof bucket.totals !== "object") {
|
|
1630
|
+
bucket.totals = initTotals();
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
if (bucket.queuedKey != null && typeof bucket.queuedKey !== "string") {
|
|
1634
|
+
bucket.queuedKey = null;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
if (projectRef) bucket.project_ref = projectRef;
|
|
1638
|
+
if (projectKey) bucket.project_key = projectKey;
|
|
1639
|
+
bucket.source = normalizedSource;
|
|
1640
|
+
bucket.hour_start = hourStart;
|
|
1641
|
+
|
|
1642
|
+
return bucket;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
function initTotals() {
|
|
1646
|
+
return {
|
|
1647
|
+
input_tokens: 0,
|
|
1648
|
+
cached_input_tokens: 0,
|
|
1649
|
+
output_tokens: 0,
|
|
1650
|
+
reasoning_output_tokens: 0,
|
|
1651
|
+
total_tokens: 0,
|
|
1652
|
+
conversation_count: 0,
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
function addTotals(target, delta) {
|
|
1657
|
+
target.input_tokens += delta.input_tokens || 0;
|
|
1658
|
+
target.cached_input_tokens += delta.cached_input_tokens || 0;
|
|
1659
|
+
target.output_tokens += delta.output_tokens || 0;
|
|
1660
|
+
target.reasoning_output_tokens += delta.reasoning_output_tokens || 0;
|
|
1661
|
+
target.total_tokens += delta.total_tokens || 0;
|
|
1662
|
+
target.conversation_count += delta.conversation_count || 0;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
function totalsKey(totals) {
|
|
1666
|
+
return [
|
|
1667
|
+
totals.input_tokens || 0,
|
|
1668
|
+
totals.cached_input_tokens || 0,
|
|
1669
|
+
totals.output_tokens || 0,
|
|
1670
|
+
totals.reasoning_output_tokens || 0,
|
|
1671
|
+
totals.total_tokens || 0,
|
|
1672
|
+
totals.conversation_count || 0,
|
|
1673
|
+
].join("|");
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
function toUtcHalfHourStart(ts) {
|
|
1677
|
+
const dt = new Date(ts);
|
|
1678
|
+
if (!Number.isFinite(dt.getTime())) return null;
|
|
1679
|
+
const minutes = dt.getUTCMinutes();
|
|
1680
|
+
const halfMinute = minutes >= 30 ? 30 : 0;
|
|
1681
|
+
const bucketStart = new Date(
|
|
1682
|
+
Date.UTC(
|
|
1683
|
+
dt.getUTCFullYear(),
|
|
1684
|
+
dt.getUTCMonth(),
|
|
1685
|
+
dt.getUTCDate(),
|
|
1686
|
+
dt.getUTCHours(),
|
|
1687
|
+
halfMinute,
|
|
1688
|
+
0,
|
|
1689
|
+
0,
|
|
1690
|
+
),
|
|
1691
|
+
);
|
|
1692
|
+
return bucketStart.toISOString();
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
function bucketKey(source, model, hourStart) {
|
|
1696
|
+
const safeSource = normalizeSourceInput(source) || DEFAULT_SOURCE;
|
|
1697
|
+
const safeModel = normalizeModelInput(model) || DEFAULT_MODEL;
|
|
1698
|
+
return `${safeSource}${BUCKET_SEPARATOR}${safeModel}${BUCKET_SEPARATOR}${hourStart}`;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
function projectBucketKey(projectKey, source, hourStart) {
|
|
1702
|
+
const safeSource = normalizeSourceInput(source) || DEFAULT_SOURCE;
|
|
1703
|
+
return `${projectKey}${BUCKET_SEPARATOR}${safeSource}${BUCKET_SEPARATOR}${hourStart}`;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
function groupBucketKey(source, hourStart) {
|
|
1707
|
+
const safeSource = normalizeSourceInput(source) || DEFAULT_SOURCE;
|
|
1708
|
+
return `${safeSource}${BUCKET_SEPARATOR}${hourStart}`;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
function parseBucketKey(key) {
|
|
1712
|
+
if (typeof key !== "string")
|
|
1713
|
+
return { source: DEFAULT_SOURCE, model: DEFAULT_MODEL, hourStart: "" };
|
|
1714
|
+
const first = key.indexOf(BUCKET_SEPARATOR);
|
|
1715
|
+
if (first <= 0) return { source: DEFAULT_SOURCE, model: DEFAULT_MODEL, hourStart: key };
|
|
1716
|
+
const second = key.indexOf(BUCKET_SEPARATOR, first + 1);
|
|
1717
|
+
if (second <= 0) {
|
|
1718
|
+
return { source: key.slice(0, first), model: DEFAULT_MODEL, hourStart: key.slice(first + 1) };
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
source: key.slice(0, first),
|
|
1722
|
+
model: key.slice(first + 1, second),
|
|
1723
|
+
hourStart: key.slice(second + 1),
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
function normalizeSourceInput(value) {
|
|
1728
|
+
if (typeof value !== "string") return null;
|
|
1729
|
+
const trimmed = value.trim().toLowerCase();
|
|
1730
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
function normalizeModelInput(value) {
|
|
1734
|
+
if (typeof value !== "string") return null;
|
|
1735
|
+
const trimmed = value.trim();
|
|
1736
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
async function resolveProjectMetaForPath(startDir, cache) {
|
|
1740
|
+
if (!startDir || typeof startDir !== "string") return null;
|
|
1741
|
+
if (cache && cache.has(startDir)) return cache.get(startDir);
|
|
1742
|
+
|
|
1743
|
+
const visited = [];
|
|
1744
|
+
let current = startDir;
|
|
1745
|
+
const root = path.parse(startDir).root;
|
|
1746
|
+
while (current) {
|
|
1747
|
+
if (cache && cache.has(current)) {
|
|
1748
|
+
const cached = cache.get(current);
|
|
1749
|
+
for (const entry of visited) cache.set(entry, cached);
|
|
1750
|
+
return cached;
|
|
1751
|
+
}
|
|
1752
|
+
visited.push(current);
|
|
1753
|
+
|
|
1754
|
+
const configPath = await resolveGitConfigPath(current);
|
|
1755
|
+
if (configPath) {
|
|
1756
|
+
const remoteUrl = await readGitRemoteUrl(configPath);
|
|
1757
|
+
const projectRef = canonicalizeProjectRef(remoteUrl);
|
|
1758
|
+
const meta = { projectRef: projectRef || null, repoRoot: current };
|
|
1759
|
+
if (cache) {
|
|
1760
|
+
for (const entry of visited) cache.set(entry, meta);
|
|
1761
|
+
}
|
|
1762
|
+
return meta;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
if (current === root) break;
|
|
1766
|
+
const parent = path.dirname(current);
|
|
1767
|
+
if (!parent || parent === current) break;
|
|
1768
|
+
current = parent;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
if (cache) {
|
|
1772
|
+
for (const entry of visited) cache.set(entry, null);
|
|
1773
|
+
}
|
|
1774
|
+
return null;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
async function defaultPublicRepoResolver({ projectRef, repoRoot, cache }) {
|
|
1778
|
+
if (!projectRef) {
|
|
1779
|
+
return {
|
|
1780
|
+
status: "blocked",
|
|
1781
|
+
projectKey: null,
|
|
1782
|
+
projectRef: null,
|
|
1783
|
+
repoRootHash: repoRoot ? hashRepoRoot(repoRoot) : null,
|
|
1784
|
+
reason: "missing_ref",
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
const cached = cache && cache.has(projectRef) ? cache.get(projectRef) : null;
|
|
1789
|
+
const base = cached || (await resolveGitHubPublicStatus(projectRef));
|
|
1790
|
+
if (cache && !cached) cache.set(projectRef, base);
|
|
1791
|
+
return {
|
|
1792
|
+
...base,
|
|
1793
|
+
repoRootHash: repoRoot ? hashRepoRoot(repoRoot) : null,
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
function recordProjectMeta(projectState, meta) {
|
|
1798
|
+
if (!projectState || !meta || typeof meta !== "object") return;
|
|
1799
|
+
const repoRootHash = typeof meta.repoRootHash === "string" ? meta.repoRootHash : null;
|
|
1800
|
+
let projectKey = typeof meta.projectKey === "string" ? meta.projectKey : null;
|
|
1801
|
+
if (
|
|
1802
|
+
!projectKey &&
|
|
1803
|
+
repoRootHash &&
|
|
1804
|
+
projectState.projects &&
|
|
1805
|
+
typeof projectState.projects === "object"
|
|
1806
|
+
) {
|
|
1807
|
+
for (const [key, entry] of Object.entries(projectState.projects)) {
|
|
1808
|
+
if (entry && entry.repo_root_hash === repoRootHash) {
|
|
1809
|
+
projectKey = key;
|
|
1810
|
+
break;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
if (!projectKey) return;
|
|
1815
|
+
if (!projectState.projects || typeof projectState.projects !== "object") {
|
|
1816
|
+
projectState.projects = {};
|
|
1817
|
+
}
|
|
1818
|
+
const prev = projectState.projects[projectKey] || {};
|
|
1819
|
+
const status = typeof meta.status === "string" ? meta.status : null;
|
|
1820
|
+
const projectRef = typeof meta.projectRef === "string" ? meta.projectRef : null;
|
|
1821
|
+
const next = {
|
|
1822
|
+
...prev,
|
|
1823
|
+
project_ref: projectRef || prev.project_ref || null,
|
|
1824
|
+
status: status || prev.status || null,
|
|
1825
|
+
repo_root_hash: repoRootHash || prev.repo_root_hash || null,
|
|
1826
|
+
updated_at: new Date().toISOString(),
|
|
1827
|
+
};
|
|
1828
|
+
if (status === "blocked" && prev.status !== "blocked") {
|
|
1829
|
+
next.purge_pending = true;
|
|
1830
|
+
} else if (status && status !== "blocked") {
|
|
1831
|
+
next.purge_pending = false;
|
|
1832
|
+
}
|
|
1833
|
+
projectState.projects[projectKey] = next;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
async function resolveProjectContextForFile({
|
|
1837
|
+
filePath,
|
|
1838
|
+
projectMetaCache,
|
|
1839
|
+
publicRepoCache,
|
|
1840
|
+
publicRepoResolver,
|
|
1841
|
+
projectState,
|
|
1842
|
+
}) {
|
|
1843
|
+
if (!filePath) return null;
|
|
1844
|
+
return resolveProjectContextForPath({
|
|
1845
|
+
startDir: path.dirname(filePath),
|
|
1846
|
+
projectMetaCache,
|
|
1847
|
+
publicRepoCache,
|
|
1848
|
+
publicRepoResolver,
|
|
1849
|
+
projectState,
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
async function resolveProjectContextForPath({
|
|
1854
|
+
startDir,
|
|
1855
|
+
projectMetaCache,
|
|
1856
|
+
publicRepoCache,
|
|
1857
|
+
publicRepoResolver,
|
|
1858
|
+
projectState,
|
|
1859
|
+
}) {
|
|
1860
|
+
if (!startDir) return null;
|
|
1861
|
+
const projectMeta = await resolveProjectMetaForPath(startDir, projectMetaCache);
|
|
1862
|
+
if (!projectMeta) return null;
|
|
1863
|
+
const resolver =
|
|
1864
|
+
typeof publicRepoResolver === "function" ? publicRepoResolver : defaultPublicRepoResolver;
|
|
1865
|
+
const meta = await resolver({
|
|
1866
|
+
projectRef: projectMeta.projectRef,
|
|
1867
|
+
repoRoot: projectMeta.repoRoot,
|
|
1868
|
+
cache: publicRepoCache,
|
|
1869
|
+
});
|
|
1870
|
+
const repoRootHash = projectMeta.repoRoot ? hashRepoRoot(projectMeta.repoRoot) : null;
|
|
1871
|
+
const normalized = {
|
|
1872
|
+
...(meta || {}),
|
|
1873
|
+
projectRef: meta?.projectRef || projectMeta.projectRef,
|
|
1874
|
+
projectKey: meta?.projectKey || null,
|
|
1875
|
+
status: meta?.status || "blocked",
|
|
1876
|
+
repoRootHash: meta?.repoRootHash || repoRootHash,
|
|
1877
|
+
};
|
|
1878
|
+
recordProjectMeta(projectState, normalized);
|
|
1879
|
+
if (normalized.status !== "public_verified") {
|
|
1880
|
+
return { projectRef: normalized.projectRef, projectKey: null, status: normalized.status };
|
|
1881
|
+
}
|
|
1882
|
+
return {
|
|
1883
|
+
projectRef: normalized.projectRef,
|
|
1884
|
+
projectKey: normalized.projectKey,
|
|
1885
|
+
status: normalized.status,
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
async function resolveGitConfigPath(rootDir) {
|
|
1890
|
+
const gitPath = path.join(rootDir, ".git");
|
|
1891
|
+
const st = await fs.stat(gitPath).catch(() => null);
|
|
1892
|
+
if (!st) return null;
|
|
1893
|
+
if (st.isDirectory()) {
|
|
1894
|
+
const configPath = path.join(gitPath, "config");
|
|
1895
|
+
const cfg = await fs.stat(configPath).catch(() => null);
|
|
1896
|
+
return cfg && cfg.isFile() ? configPath : null;
|
|
1897
|
+
}
|
|
1898
|
+
if (st.isFile()) {
|
|
1899
|
+
const content = await fs.readFile(gitPath, "utf8").catch(() => "");
|
|
1900
|
+
const match = content.match(/gitdir:\s*(.+)/i);
|
|
1901
|
+
if (!match) return null;
|
|
1902
|
+
let gitDir = match[1].trim();
|
|
1903
|
+
if (!gitDir) return null;
|
|
1904
|
+
if (!path.isAbsolute(gitDir)) {
|
|
1905
|
+
gitDir = path.resolve(rootDir, gitDir);
|
|
1906
|
+
}
|
|
1907
|
+
const configPath = path.join(gitDir, "config");
|
|
1908
|
+
const cfg = await fs.stat(configPath).catch(() => null);
|
|
1909
|
+
if (cfg && cfg.isFile()) return configPath;
|
|
1910
|
+
|
|
1911
|
+
const commonDirRaw = await fs.readFile(path.join(gitDir, "commondir"), "utf8").catch(() => "");
|
|
1912
|
+
const commonDirRel = commonDirRaw.trim();
|
|
1913
|
+
if (!commonDirRel) return null;
|
|
1914
|
+
let commonDir = commonDirRel;
|
|
1915
|
+
if (!path.isAbsolute(commonDir)) {
|
|
1916
|
+
commonDir = path.resolve(gitDir, commonDir);
|
|
1917
|
+
}
|
|
1918
|
+
const commonConfigPath = path.join(commonDir, "config");
|
|
1919
|
+
const commonCfg = await fs.stat(commonConfigPath).catch(() => null);
|
|
1920
|
+
return commonCfg && commonCfg.isFile() ? commonConfigPath : null;
|
|
1921
|
+
}
|
|
1922
|
+
return null;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
async function readGitRemoteUrl(configPath) {
|
|
1926
|
+
const raw = await fs.readFile(configPath, "utf8").catch(() => "");
|
|
1927
|
+
if (!raw.trim()) return null;
|
|
1928
|
+
|
|
1929
|
+
const remotes = new Map();
|
|
1930
|
+
let current = null;
|
|
1931
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
1932
|
+
const sectionHeader = line.match(/^\s*\[[^\]]+\]\s*$/);
|
|
1933
|
+
if (sectionHeader) {
|
|
1934
|
+
const sectionMatch = line.match(/^\s*\[remote\s+"([^"]+)"\]\s*$/i);
|
|
1935
|
+
current = sectionMatch ? sectionMatch[1] : null;
|
|
1936
|
+
continue;
|
|
1937
|
+
}
|
|
1938
|
+
if (!current) continue;
|
|
1939
|
+
const urlMatch = line.match(/^\s*url\s*=\s*(.+)\s*$/i);
|
|
1940
|
+
if (urlMatch) {
|
|
1941
|
+
remotes.set(current, urlMatch[1].trim());
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
if (remotes.has("origin")) return remotes.get("origin");
|
|
1946
|
+
const first = remotes.values().next();
|
|
1947
|
+
return first.done ? null : first.value;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
function canonicalizeProjectRef(remoteUrl) {
|
|
1951
|
+
if (typeof remoteUrl !== "string") return null;
|
|
1952
|
+
let ref = remoteUrl.trim();
|
|
1953
|
+
if (!ref) return null;
|
|
1954
|
+
|
|
1955
|
+
if (ref.startsWith("file://")) return null;
|
|
1956
|
+
if (path.isAbsolute(ref) || path.win32.isAbsolute(ref)) return null;
|
|
1957
|
+
|
|
1958
|
+
const gitAtMatch = ref.match(/^git@([^:]+):(.+)$/i);
|
|
1959
|
+
if (gitAtMatch) {
|
|
1960
|
+
ref = `https://${gitAtMatch[1]}/${gitAtMatch[2]}`;
|
|
1961
|
+
} else if (ref.startsWith("ssh://")) {
|
|
1962
|
+
try {
|
|
1963
|
+
const parsed = new URL(ref);
|
|
1964
|
+
ref = `https://${parsed.hostname}${parsed.pathname}`;
|
|
1965
|
+
} catch (_e) {
|
|
1966
|
+
return null;
|
|
1967
|
+
}
|
|
1968
|
+
} else if (ref.startsWith("git://")) {
|
|
1969
|
+
ref = `https://${ref.slice("git://".length)}`;
|
|
1970
|
+
} else if (ref.startsWith("http://")) {
|
|
1971
|
+
ref = `https://${ref.slice("http://".length)}`;
|
|
1972
|
+
} else if (!ref.startsWith("https://")) {
|
|
1973
|
+
return null;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
try {
|
|
1977
|
+
const parsed = new URL(ref);
|
|
1978
|
+
if (!parsed.hostname) return null;
|
|
1979
|
+
ref = `https://${parsed.hostname}${parsed.pathname}`;
|
|
1980
|
+
} catch (_e) {
|
|
1981
|
+
return null;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
ref = ref.replace(/\.git$/i, "");
|
|
1985
|
+
ref = ref.replace(/\/+$/, "");
|
|
1986
|
+
return ref || null;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
function normalizeGeminiTokens(tokens) {
|
|
1990
|
+
if (!tokens || typeof tokens !== "object") return null;
|
|
1991
|
+
const input = toNonNegativeInt(tokens.input);
|
|
1992
|
+
const cached = toNonNegativeInt(tokens.cached);
|
|
1993
|
+
const output = toNonNegativeInt(tokens.output);
|
|
1994
|
+
const tool = toNonNegativeInt(tokens.tool);
|
|
1995
|
+
const thoughts = toNonNegativeInt(tokens.thoughts);
|
|
1996
|
+
const total = toNonNegativeInt(tokens.total);
|
|
1997
|
+
|
|
1998
|
+
return {
|
|
1999
|
+
input_tokens: input,
|
|
2000
|
+
cached_input_tokens: cached,
|
|
2001
|
+
output_tokens: output + tool,
|
|
2002
|
+
reasoning_output_tokens: thoughts,
|
|
2003
|
+
total_tokens: total,
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
function normalizeOpencodeTokens(tokens) {
|
|
2008
|
+
if (!tokens || typeof tokens !== "object") return null;
|
|
2009
|
+
const input = toNonNegativeInt(tokens.input);
|
|
2010
|
+
const output = toNonNegativeInt(tokens.output);
|
|
2011
|
+
const reasoning = toNonNegativeInt(tokens.reasoning);
|
|
2012
|
+
const cached = toNonNegativeInt(tokens.cache?.read);
|
|
2013
|
+
const cacheWrite = toNonNegativeInt(tokens.cache?.write);
|
|
2014
|
+
// cache tokens (read/write) excluded from input_tokens and total_tokens
|
|
2015
|
+
const total = input + output + reasoning;
|
|
2016
|
+
|
|
2017
|
+
return {
|
|
2018
|
+
input_tokens: input,
|
|
2019
|
+
cached_input_tokens: cached,
|
|
2020
|
+
output_tokens: output,
|
|
2021
|
+
reasoning_output_tokens: reasoning,
|
|
2022
|
+
total_tokens: total,
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
function sameGeminiTotals(a, b) {
|
|
2027
|
+
if (!a || !b) return false;
|
|
2028
|
+
return (
|
|
2029
|
+
a.input_tokens === b.input_tokens &&
|
|
2030
|
+
a.cached_input_tokens === b.cached_input_tokens &&
|
|
2031
|
+
a.output_tokens === b.output_tokens &&
|
|
2032
|
+
a.reasoning_output_tokens === b.reasoning_output_tokens &&
|
|
2033
|
+
a.total_tokens === b.total_tokens
|
|
2034
|
+
);
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
function diffGeminiTotals(current, previous) {
|
|
2038
|
+
if (!current || typeof current !== "object") return null;
|
|
2039
|
+
if (!previous || typeof previous !== "object") return current;
|
|
2040
|
+
if (sameGeminiTotals(current, previous)) return null;
|
|
2041
|
+
|
|
2042
|
+
const totalReset = (current.total_tokens || 0) < (previous.total_tokens || 0);
|
|
2043
|
+
if (totalReset) return current;
|
|
2044
|
+
|
|
2045
|
+
const delta = {
|
|
2046
|
+
input_tokens: Math.max(0, (current.input_tokens || 0) - (previous.input_tokens || 0)),
|
|
2047
|
+
cached_input_tokens: Math.max(
|
|
2048
|
+
0,
|
|
2049
|
+
(current.cached_input_tokens || 0) - (previous.cached_input_tokens || 0),
|
|
2050
|
+
),
|
|
2051
|
+
output_tokens: Math.max(0, (current.output_tokens || 0) - (previous.output_tokens || 0)),
|
|
2052
|
+
reasoning_output_tokens: Math.max(
|
|
2053
|
+
0,
|
|
2054
|
+
(current.reasoning_output_tokens || 0) - (previous.reasoning_output_tokens || 0),
|
|
2055
|
+
),
|
|
2056
|
+
total_tokens: Math.max(0, (current.total_tokens || 0) - (previous.total_tokens || 0)),
|
|
2057
|
+
};
|
|
2058
|
+
|
|
2059
|
+
return isAllZeroUsage(delta) ? null : delta;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
function extractTokenCount(obj) {
|
|
2063
|
+
const payload = obj?.payload;
|
|
2064
|
+
if (!payload) return null;
|
|
2065
|
+
if (payload.type === "token_count") {
|
|
2066
|
+
return { info: payload.info, timestamp: obj?.timestamp || null };
|
|
2067
|
+
}
|
|
2068
|
+
const msg = payload.msg;
|
|
2069
|
+
if (msg && msg.type === "token_count") {
|
|
2070
|
+
return { info: msg.info, timestamp: obj?.timestamp || null };
|
|
2071
|
+
}
|
|
2072
|
+
return null;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
function pickDelta(lastUsage, totalUsage, prevTotals) {
|
|
2076
|
+
const hasLast = isNonEmptyObject(lastUsage);
|
|
2077
|
+
const hasTotal = isNonEmptyObject(totalUsage);
|
|
2078
|
+
const hasPrevTotals = isNonEmptyObject(prevTotals);
|
|
2079
|
+
|
|
2080
|
+
// Codex rollout logs sometimes emit duplicate token_count records where total_token_usage does not
|
|
2081
|
+
// change between adjacent entries. Counting last_token_usage in those cases will double-count.
|
|
2082
|
+
if (hasTotal && hasPrevTotals && sameUsage(totalUsage, prevTotals)) {
|
|
2083
|
+
return null;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
if (!hasLast && hasTotal && hasPrevTotals && totalsReset(totalUsage, prevTotals)) {
|
|
2087
|
+
const normalized = normalizeUsage(totalUsage);
|
|
2088
|
+
return isAllZeroUsage(normalized) ? null : normalized;
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
if (hasLast) {
|
|
2092
|
+
return normalizeUsage(lastUsage);
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
if (hasTotal && hasPrevTotals) {
|
|
2096
|
+
const delta = {};
|
|
2097
|
+
for (const k of [
|
|
2098
|
+
"input_tokens",
|
|
2099
|
+
"cached_input_tokens",
|
|
2100
|
+
"output_tokens",
|
|
2101
|
+
"reasoning_output_tokens",
|
|
2102
|
+
"total_tokens",
|
|
2103
|
+
]) {
|
|
2104
|
+
const a = Number(totalUsage[k]);
|
|
2105
|
+
const b = Number(prevTotals[k]);
|
|
2106
|
+
if (Number.isFinite(a) && Number.isFinite(b)) delta[k] = Math.max(0, a - b);
|
|
2107
|
+
}
|
|
2108
|
+
const normalized = normalizeUsage(delta);
|
|
2109
|
+
return isAllZeroUsage(normalized) ? null : normalized;
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
if (hasTotal) {
|
|
2113
|
+
const normalized = normalizeUsage(totalUsage);
|
|
2114
|
+
return isAllZeroUsage(normalized) ? null : normalized;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
return null;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
function normalizeUsage(u) {
|
|
2121
|
+
const out = {};
|
|
2122
|
+
for (const k of [
|
|
2123
|
+
"input_tokens",
|
|
2124
|
+
"cached_input_tokens",
|
|
2125
|
+
"output_tokens",
|
|
2126
|
+
"reasoning_output_tokens",
|
|
2127
|
+
"total_tokens",
|
|
2128
|
+
]) {
|
|
2129
|
+
const n = Number(u[k] || 0);
|
|
2130
|
+
out[k] = Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0;
|
|
2131
|
+
}
|
|
2132
|
+
return out;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
function normalizeClaudeUsage(u) {
|
|
2136
|
+
const inputTokens = toNonNegativeInt(u?.input_tokens);
|
|
2137
|
+
const outputTokens = toNonNegativeInt(u?.output_tokens);
|
|
2138
|
+
const hasTotal = u && Object.prototype.hasOwnProperty.call(u, "total_tokens");
|
|
2139
|
+
const totalTokens = hasTotal
|
|
2140
|
+
? toNonNegativeInt(u?.total_tokens)
|
|
2141
|
+
: inputTokens + outputTokens;
|
|
2142
|
+
return {
|
|
2143
|
+
input_tokens: inputTokens,
|
|
2144
|
+
cached_input_tokens: toNonNegativeInt(u?.cache_read_input_tokens),
|
|
2145
|
+
output_tokens: outputTokens,
|
|
2146
|
+
reasoning_output_tokens: 0,
|
|
2147
|
+
total_tokens: totalTokens,
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
function isNonEmptyObject(v) {
|
|
2152
|
+
return Boolean(v && typeof v === "object" && !Array.isArray(v) && Object.keys(v).length > 0);
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
function isAllZeroUsage(u) {
|
|
2156
|
+
if (!u || typeof u !== "object") return true;
|
|
2157
|
+
for (const k of [
|
|
2158
|
+
"input_tokens",
|
|
2159
|
+
"cached_input_tokens",
|
|
2160
|
+
"output_tokens",
|
|
2161
|
+
"reasoning_output_tokens",
|
|
2162
|
+
"total_tokens",
|
|
2163
|
+
]) {
|
|
2164
|
+
if (Number(u[k] || 0) !== 0) return false;
|
|
2165
|
+
}
|
|
2166
|
+
return true;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
function sameUsage(a, b) {
|
|
2170
|
+
for (const k of [
|
|
2171
|
+
"input_tokens",
|
|
2172
|
+
"cached_input_tokens",
|
|
2173
|
+
"output_tokens",
|
|
2174
|
+
"reasoning_output_tokens",
|
|
2175
|
+
"total_tokens",
|
|
2176
|
+
]) {
|
|
2177
|
+
if (toNonNegativeInt(a?.[k]) !== toNonNegativeInt(b?.[k])) return false;
|
|
2178
|
+
}
|
|
2179
|
+
return true;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
function totalsReset(curr, prev) {
|
|
2183
|
+
const currTotal = curr?.total_tokens;
|
|
2184
|
+
const prevTotal = prev?.total_tokens;
|
|
2185
|
+
if (!isFiniteNumber(currTotal) || !isFiniteNumber(prevTotal)) return false;
|
|
2186
|
+
return currTotal < prevTotal;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
function isFiniteNumber(v) {
|
|
2190
|
+
return typeof v === "number" && Number.isFinite(v);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
function toNonNegativeInt(v) {
|
|
2194
|
+
const n = Number(v);
|
|
2195
|
+
if (!Number.isFinite(n) || n < 0) return 0;
|
|
2196
|
+
return Math.floor(n);
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
function coerceEpochMs(v) {
|
|
2200
|
+
const n = Number(v);
|
|
2201
|
+
if (!Number.isFinite(n) || n <= 0) return 0;
|
|
2202
|
+
if (n < 1e12) return Math.floor(n * 1000);
|
|
2203
|
+
return Math.floor(n);
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
async function safeReadDir(dir) {
|
|
2207
|
+
try {
|
|
2208
|
+
return await fs.readdir(dir, { withFileTypes: true });
|
|
2209
|
+
} catch (_e) {
|
|
2210
|
+
return [];
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
async function walkClaudeProjects(dir, out) {
|
|
2215
|
+
const entries = await safeReadDir(dir);
|
|
2216
|
+
for (const entry of entries) {
|
|
2217
|
+
const fullPath = path.join(dir, entry.name);
|
|
2218
|
+
if (entry.isDirectory()) {
|
|
2219
|
+
await walkClaudeProjects(fullPath, out);
|
|
2220
|
+
continue;
|
|
2221
|
+
}
|
|
2222
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) out.push(fullPath);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
async function walkOpencodeMessages(dir, out) {
|
|
2227
|
+
const entries = await safeReadDir(dir);
|
|
2228
|
+
for (const entry of entries) {
|
|
2229
|
+
const fullPath = path.join(dir, entry.name);
|
|
2230
|
+
if (entry.isDirectory()) {
|
|
2231
|
+
await walkOpencodeMessages(fullPath, out);
|
|
2232
|
+
continue;
|
|
2233
|
+
}
|
|
2234
|
+
if (entry.isFile() && entry.name.startsWith("msg_") && entry.name.endsWith(".json"))
|
|
2235
|
+
out.push(fullPath);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
// ---------------------------------------------------------------------------
|
|
2240
|
+
// OpenCode SQLite DB reader (v1.2+ stores messages in opencode.db)
|
|
2241
|
+
// ---------------------------------------------------------------------------
|
|
2242
|
+
|
|
2243
|
+
function readOpencodeDbMessages(dbPath) {
|
|
2244
|
+
if (!dbPath || !fssync.existsSync(dbPath)) return [];
|
|
2245
|
+
const sql = `SELECT id, session_id, time_updated, data FROM message WHERE json_extract(data, '$.role') = 'assistant' ORDER BY time_created ASC`;
|
|
2246
|
+
let raw;
|
|
2247
|
+
try {
|
|
2248
|
+
raw = cp.execFileSync("sqlite3", ["-json", dbPath, sql], {
|
|
2249
|
+
encoding: "utf8",
|
|
2250
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
2251
|
+
timeout: 30_000,
|
|
2252
|
+
});
|
|
2253
|
+
} catch (_e) {
|
|
2254
|
+
return [];
|
|
2255
|
+
}
|
|
2256
|
+
if (!raw || !raw.trim()) return [];
|
|
2257
|
+
let rows;
|
|
2258
|
+
try {
|
|
2259
|
+
rows = JSON.parse(raw);
|
|
2260
|
+
} catch (_e) {
|
|
2261
|
+
return [];
|
|
2262
|
+
}
|
|
2263
|
+
if (!Array.isArray(rows)) return [];
|
|
2264
|
+
const out = [];
|
|
2265
|
+
for (const row of rows) {
|
|
2266
|
+
if (!row || typeof row.data !== "string") continue;
|
|
2267
|
+
let data;
|
|
2268
|
+
try {
|
|
2269
|
+
data = JSON.parse(row.data);
|
|
2270
|
+
} catch (_e) {
|
|
2271
|
+
continue;
|
|
2272
|
+
}
|
|
2273
|
+
const tokens = data?.tokens;
|
|
2274
|
+
if (!tokens || typeof tokens !== "object") continue;
|
|
2275
|
+
// Skip messages with no meaningful token data
|
|
2276
|
+
const hasTokens =
|
|
2277
|
+
toNonNegativeInt(tokens.input) > 0 ||
|
|
2278
|
+
toNonNegativeInt(tokens.output) > 0 ||
|
|
2279
|
+
toNonNegativeInt(tokens.reasoning) > 0;
|
|
2280
|
+
if (!hasTokens) continue;
|
|
2281
|
+
out.push({
|
|
2282
|
+
id: row.id || data.id,
|
|
2283
|
+
sessionID: row.session_id || data.sessionID,
|
|
2284
|
+
timeUpdated: row.time_updated || 0,
|
|
2285
|
+
data,
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
return out;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
async function parseOpencodeDbIncremental({
|
|
2292
|
+
dbMessages,
|
|
2293
|
+
cursors,
|
|
2294
|
+
queuePath,
|
|
2295
|
+
projectQueuePath,
|
|
2296
|
+
onProgress,
|
|
2297
|
+
source,
|
|
2298
|
+
publicRepoResolver,
|
|
2299
|
+
}) {
|
|
2300
|
+
await ensureDir(path.dirname(queuePath));
|
|
2301
|
+
let messagesProcessed = 0;
|
|
2302
|
+
let eventsAggregated = 0;
|
|
2303
|
+
|
|
2304
|
+
const cb = typeof onProgress === "function" ? onProgress : null;
|
|
2305
|
+
const messages = Array.isArray(dbMessages) ? dbMessages : [];
|
|
2306
|
+
const totalMessages = messages.length;
|
|
2307
|
+
const hourlyState = normalizeHourlyState(cursors?.hourly);
|
|
2308
|
+
const projectEnabled = typeof projectQueuePath === "string" && projectQueuePath.length > 0;
|
|
2309
|
+
const projectState = projectEnabled ? normalizeProjectState(cursors?.projectHourly) : null;
|
|
2310
|
+
const projectTouchedBuckets = projectEnabled ? new Set() : null;
|
|
2311
|
+
const projectMetaCache = projectEnabled ? new Map() : null;
|
|
2312
|
+
const publicRepoCache = projectEnabled ? new Map() : null;
|
|
2313
|
+
const opencodeState = normalizeOpencodeState(cursors?.opencode);
|
|
2314
|
+
const messageIndex = opencodeState.messages;
|
|
2315
|
+
const touchedBuckets = new Set();
|
|
2316
|
+
const defaultSource = normalizeSourceInput(source) || "opencode";
|
|
2317
|
+
|
|
2318
|
+
for (let idx = 0; idx < messages.length; idx++) {
|
|
2319
|
+
const entry = messages[idx];
|
|
2320
|
+
const msg = entry.data;
|
|
2321
|
+
if (!msg) continue;
|
|
2322
|
+
|
|
2323
|
+
// DB stores id/sessionID as separate columns; inject into msg for key derivation
|
|
2324
|
+
const msgForKey = { ...msg };
|
|
2325
|
+
if (entry.id && !msgForKey.id) msgForKey.id = entry.id;
|
|
2326
|
+
if (entry.sessionID && !msgForKey.sessionID) msgForKey.sessionID = entry.sessionID;
|
|
2327
|
+
const messageKey = deriveOpencodeMessageKey(msgForKey, null);
|
|
2328
|
+
if (!messageKey) {
|
|
2329
|
+
messagesProcessed += 1;
|
|
2330
|
+
continue;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
// Skip messages already indexed (from prior JSON-file parsing or previous DB sync)
|
|
2334
|
+
const prev = messageIndex[messageKey];
|
|
2335
|
+
const lastTotals = prev && typeof prev.lastTotals === "object" ? prev.lastTotals : null;
|
|
2336
|
+
|
|
2337
|
+
const currentTotals = normalizeOpencodeTokens(msg?.tokens);
|
|
2338
|
+
if (!currentTotals) {
|
|
2339
|
+
messagesProcessed += 1;
|
|
2340
|
+
continue;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
const delta = diffGeminiTotals(currentTotals, lastTotals);
|
|
2344
|
+
if (!delta || isAllZeroUsage(delta)) {
|
|
2345
|
+
// Update index with current totals even if no delta (normalization may have changed)
|
|
2346
|
+
if (!sameGeminiTotals(currentTotals, lastTotals)) {
|
|
2347
|
+
messageIndex[messageKey] = {
|
|
2348
|
+
lastTotals: currentTotals,
|
|
2349
|
+
updatedAt: new Date().toISOString(),
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
messagesProcessed += 1;
|
|
2353
|
+
if (cb) {
|
|
2354
|
+
cb({
|
|
2355
|
+
index: idx + 1,
|
|
2356
|
+
total: totalMessages,
|
|
2357
|
+
messagesProcessed,
|
|
2358
|
+
eventsAggregated,
|
|
2359
|
+
bucketsQueued: touchedBuckets.size,
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
continue;
|
|
2363
|
+
}
|
|
2364
|
+
delta.conversation_count = 1;
|
|
2365
|
+
|
|
2366
|
+
const timestampMs = coerceEpochMs(msg?.time?.completed) || coerceEpochMs(msg?.time?.created);
|
|
2367
|
+
if (!timestampMs) {
|
|
2368
|
+
messagesProcessed += 1;
|
|
2369
|
+
continue;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
const tsIso = new Date(timestampMs).toISOString();
|
|
2373
|
+
const bucketStart = toUtcHalfHourStart(tsIso);
|
|
2374
|
+
if (!bucketStart) {
|
|
2375
|
+
messagesProcessed += 1;
|
|
2376
|
+
continue;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
const model = normalizeModelInput(msg?.modelID || msg?.model || msg?.modelId) || DEFAULT_MODEL;
|
|
2380
|
+
const bucket = getHourlyBucket(hourlyState, defaultSource, model, bucketStart);
|
|
2381
|
+
addTotals(bucket.totals, delta);
|
|
2382
|
+
touchedBuckets.add(bucketKey(defaultSource, model, bucketStart));
|
|
2383
|
+
|
|
2384
|
+
if (projectEnabled) {
|
|
2385
|
+
const projectContext = await resolveProjectContextForDb({
|
|
2386
|
+
msg,
|
|
2387
|
+
projectMetaCache,
|
|
2388
|
+
publicRepoCache,
|
|
2389
|
+
publicRepoResolver,
|
|
2390
|
+
projectState,
|
|
2391
|
+
});
|
|
2392
|
+
const projectRef = projectContext?.projectRef || null;
|
|
2393
|
+
const projectKey = projectContext?.projectKey || null;
|
|
2394
|
+
if (projectKey && projectState && projectTouchedBuckets) {
|
|
2395
|
+
const projectBucket = getProjectBucket(
|
|
2396
|
+
projectState,
|
|
2397
|
+
projectKey,
|
|
2398
|
+
defaultSource,
|
|
2399
|
+
bucketStart,
|
|
2400
|
+
projectRef,
|
|
2401
|
+
);
|
|
2402
|
+
addTotals(projectBucket.totals, delta);
|
|
2403
|
+
projectTouchedBuckets.add(projectBucketKey(projectKey, defaultSource, bucketStart));
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
messageIndex[messageKey] = {
|
|
2408
|
+
lastTotals: currentTotals,
|
|
2409
|
+
updatedAt: new Date().toISOString(),
|
|
2410
|
+
};
|
|
2411
|
+
messagesProcessed += 1;
|
|
2412
|
+
eventsAggregated += 1;
|
|
2413
|
+
|
|
2414
|
+
if (cb) {
|
|
2415
|
+
cb({
|
|
2416
|
+
index: idx + 1,
|
|
2417
|
+
total: totalMessages,
|
|
2418
|
+
messagesProcessed,
|
|
2419
|
+
eventsAggregated,
|
|
2420
|
+
bucketsQueued: touchedBuckets.size,
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
const bucketsQueued = await enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets });
|
|
2426
|
+
const projectBucketsQueued = projectEnabled
|
|
2427
|
+
? await enqueueTouchedProjectBuckets({ projectQueuePath, projectState, projectTouchedBuckets })
|
|
2428
|
+
: 0;
|
|
2429
|
+
hourlyState.updatedAt = new Date().toISOString();
|
|
2430
|
+
cursors.hourly = hourlyState;
|
|
2431
|
+
opencodeState.updatedAt = new Date().toISOString();
|
|
2432
|
+
cursors.opencode = opencodeState;
|
|
2433
|
+
if (projectState) {
|
|
2434
|
+
projectState.updatedAt = new Date().toISOString();
|
|
2435
|
+
cursors.projectHourly = projectState;
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
return { messagesProcessed, eventsAggregated, bucketsQueued, projectBucketsQueued };
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
// Resolve project context from DB message (no file path available)
|
|
2442
|
+
async function resolveProjectContextForDb({
|
|
2443
|
+
msg,
|
|
2444
|
+
projectMetaCache,
|
|
2445
|
+
publicRepoCache,
|
|
2446
|
+
publicRepoResolver,
|
|
2447
|
+
projectState,
|
|
2448
|
+
}) {
|
|
2449
|
+
const cwd = msg?.path?.cwd;
|
|
2450
|
+
if (!cwd || typeof cwd !== "string") return null;
|
|
2451
|
+
return resolveProjectContextForPath({
|
|
2452
|
+
startDir: cwd,
|
|
2453
|
+
projectMetaCache,
|
|
2454
|
+
publicRepoCache,
|
|
2455
|
+
publicRepoResolver,
|
|
2456
|
+
projectState,
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
module.exports = {
|
|
2461
|
+
listRolloutFiles,
|
|
2462
|
+
listClaudeProjectFiles,
|
|
2463
|
+
listGeminiSessionFiles,
|
|
2464
|
+
listOpencodeMessageFiles,
|
|
2465
|
+
readOpencodeDbMessages,
|
|
2466
|
+
parseRolloutIncremental,
|
|
2467
|
+
parseClaudeIncremental,
|
|
2468
|
+
parseGeminiIncremental,
|
|
2469
|
+
parseOpencodeIncremental,
|
|
2470
|
+
parseOpencodeDbIncremental,
|
|
2471
|
+
parseOpenclawIncremental,
|
|
2472
|
+
};
|