@cartanova/qgrid-cli 2.10.10 → 2.11.1
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/bundle/dist/_virtual/_rolldown/runtime.js +1 -10
- package/bundle/dist/application/monit/log-buffer.js +12 -6
- package/bundle/dist/application/monit/monit.frame.js +11 -3
- package/bundle/dist/application/monit/monit.types.js +1 -1
- package/bundle/dist/application/qgrid/conv-routing.js +9 -6
- package/bundle/dist/application/qgrid/expired-token-reminder.js +2 -2
- package/bundle/dist/application/qgrid/oauth.js +31 -4
- package/bundle/dist/application/qgrid/qgrid-image-generation.js +1 -1
- package/bundle/dist/application/qgrid/qgrid-response-format.js +21 -19
- package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +40 -33
- package/bundle/dist/application/qgrid/qgrid.dispatcher.js +128 -93
- package/bundle/dist/application/qgrid/qgrid.frame.js +930 -49
- package/bundle/dist/application/qgrid/qgrid.types.js +212 -5
- package/bundle/dist/application/qgrid/schema-prompt.js +75 -48
- package/bundle/dist/application/qgrid/slack-user-map.js +1 -1
- package/bundle/dist/application/qgrid/token-death.js +1 -1
- package/bundle/dist/application/qgrid/token-subscriber.js +83 -30
- package/bundle/dist/application/qgrid/token-trigger-setup.js +1 -1
- package/bundle/dist/application/qgrid/token-window-keepalive.js +8 -6
- package/bundle/dist/application/qgrid/tool-emulation-schema.js +13 -13
- package/bundle/dist/application/qgrid/tool-emulation.js +19 -15
- package/bundle/dist/application/request-log/json-schema-type-text.js +29 -12
- package/bundle/dist/application/request-log/request-log.model.js +83 -70
- package/bundle/dist/application/request-log/request-log.types.js +1 -1
- package/bundle/dist/application/request-log/zod-code-format.js +1 -1
- package/bundle/dist/application/request-log-step/request-log-step.model.js +1 -1
- package/bundle/dist/application/request-log-step/request-log-step.types.js +1 -1
- package/bundle/dist/application/setting/setting.constant.js +1 -1
- package/bundle/dist/application/setting/setting.model.js +2 -2
- package/bundle/dist/application/setting/setting.store.js +2 -2
- package/bundle/dist/application/setting/setting.types.js +1 -1
- package/bundle/dist/application/sonamu.generated.js +32 -16
- package/bundle/dist/application/sonamu.generated.sso.js +1 -1
- package/bundle/dist/application/token/token.model.js +26 -9
- package/bundle/dist/application/token/token.types.js +20 -3
- package/bundle/dist/i18n/en.js +15 -1
- package/bundle/dist/i18n/ko.js +15 -1
- package/bundle/dist/i18n/sd.generated.js +1 -1
- package/bundle/dist/migrations/20260807133553_manual__backfill_request_log_cost.js +8 -6
- package/bundle/dist/server-bootstrap.js +4 -2
- package/bundle/dist/server-error-handler.js +1 -1
- package/bundle/dist/sonamu.config.js +37 -8
- package/bundle/dist/startup-migrations.js +17 -7
- package/bundle/dist/testing/global.js +1 -1
- package/bundle/dist/testing/schema-bench.js +0 -0
- package/bundle/dist/testing/test-database-name.js +1 -1
- package/bundle/dist/utils/providers/anthropic/anthropic-constants.js +1 -1
- package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +11 -5
- package/bundle/dist/utils/providers/anthropic/anthropic-quota.js +4 -4
- package/bundle/dist/utils/providers/anthropic/anthropic-thinking.js +1 -1
- package/bundle/dist/utils/providers/anthropic/claude-session.js +20 -19
- package/bundle/dist/utils/providers/anthropic/fence-strip.js +1 -1
- package/bundle/dist/utils/providers/anthropic/stream-json-adapter.js +49 -23
- package/bundle/dist/utils/providers/common/credentials.js +5 -1
- package/bundle/dist/utils/providers/common/effort.js +3 -3
- package/bundle/dist/utils/providers/common/model-cost.js +69 -14
- package/bundle/dist/utils/providers/common/provider-types.js +29 -1
- package/bundle/dist/utils/providers/common/schema-validation.js +78 -40
- package/bundle/dist/utils/providers/common/smooth-weighted-round-robin.js +1 -1
- package/bundle/dist/utils/providers/common/strictifier.js +62 -43
- package/bundle/dist/utils/providers/common/thinking.js +3 -2
- package/bundle/dist/utils/providers/common/ttft.js +1 -1
- package/bundle/dist/utils/providers/grok/grok-backend-protocol.js +427 -0
- package/bundle/dist/utils/providers/grok/grok-constants.js +55 -0
- package/bundle/dist/utils/providers/grok/grok-direct-client.js +196 -0
- package/bundle/dist/utils/providers/grok/grok-dispatcher.js +1313 -0
- package/bundle/dist/utils/providers/grok/grok-headers.js +118 -0
- package/bundle/dist/utils/providers/grok/grok-media-client.js +420 -0
- package/bundle/dist/utils/providers/grok/grok-models.js +114 -0
- package/bundle/dist/utils/providers/grok/grok-oauth.js +455 -0
- package/bundle/dist/utils/providers/grok/grok-quota.js +119 -0
- package/bundle/dist/utils/providers/grok/grok-refresh.js +192 -0
- package/bundle/dist/utils/providers/grok/grok-types.js +186 -0
- package/bundle/dist/utils/providers/grok/grok-voice-client.js +199 -0
- package/bundle/dist/utils/providers/grok/index.js +11 -0
- package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +111 -83
- package/bundle/dist/utils/providers/openai/openai-callback-relay.js +3 -2
- package/bundle/dist/utils/providers/openai/openai-constants.js +1 -1
- package/bundle/dist/utils/providers/openai/openai-direct-client.js +23 -7
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +143 -106
- package/bundle/dist/utils/providers/openai/openai-image-generation.js +48 -33
- package/bundle/dist/utils/providers/openai/openai-oauth.js +28 -13
- package/bundle/dist/utils/providers/openai/openai-quota.js +38 -27
- package/bundle/dist/utils/providers/openai/openai-refresh.js +17 -9
- package/bundle/dist/utils/providers/openai/openai-sse.js +1 -1
- package/bundle/dist/utils/providers/openai/openai-transport-config.js +1 -1
- package/bundle/dist/utils/quiet-hours.js +1 -1
- package/bundle/dist/utils/slack-notify.js +14 -8
- package/bundle/dist/utils/subset-loaders.js +4 -5
- package/bundle/src/application/monit/log-buffer.ts +23 -9
- package/bundle/src/application/monit/monit.frame.ts +22 -5
- package/bundle/src/application/monit/monit.types.ts +6 -0
- package/bundle/src/application/qgrid/conv-routing.test.ts +76 -4
- package/bundle/src/application/qgrid/conv-routing.ts +35 -9
- package/bundle/src/application/qgrid/expired-token-reminder.ts +9 -1
- package/bundle/src/application/qgrid/oauth.ts +51 -15
- package/bundle/src/application/qgrid/qgrid-image-generation.ts +9 -0
- package/bundle/src/application/qgrid/qgrid-response-format.ts +50 -25
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +19 -0
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +84 -40
- package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +97 -0
- package/bundle/src/application/qgrid/qgrid.dispatcher.ts +274 -126
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +1013 -3
- package/bundle/src/application/qgrid/qgrid.frame.ts +1415 -60
- package/bundle/src/application/qgrid/qgrid.types.ts +335 -0
- package/bundle/src/application/qgrid/schema-prompt.ts +105 -41
- package/bundle/src/application/qgrid/slack-user-map.ts +5 -0
- package/bundle/src/application/qgrid/token-death.ts +4 -0
- package/bundle/src/application/qgrid/token-subscriber.test.ts +21 -19
- package/bundle/src/application/qgrid/token-subscriber.ts +186 -53
- package/bundle/src/application/qgrid/token-trigger-setup.ts +2 -0
- package/bundle/src/application/qgrid/token-window-keepalive.ts +49 -6
- package/bundle/src/application/qgrid/tool-emulation-schema.ts +33 -29
- package/bundle/src/application/qgrid/tool-emulation.ts +52 -27
- package/bundle/src/application/request-log/json-schema-type-text.test.ts +5 -5
- package/bundle/src/application/request-log/json-schema-type-text.ts +81 -26
- package/bundle/src/application/request-log/request-log.model.test.ts +111 -4
- package/bundle/src/application/request-log/request-log.model.ts +277 -146
- package/bundle/src/application/request-log/request-log.types.ts +6 -0
- package/bundle/src/application/request-log/zod-code-format.ts +11 -0
- package/bundle/src/application/request-log-step/request-log-step.model.ts +1 -0
- package/bundle/src/application/request-log-step/request-log-step.types.ts +2 -0
- package/bundle/src/application/setting/setting.constant.ts +9 -0
- package/bundle/src/application/setting/setting.model.ts +12 -2
- package/bundle/src/application/setting/setting.store.ts +5 -1
- package/bundle/src/application/setting/setting.types.ts +8 -0
- package/bundle/src/application/sonamu.generated.http +133 -0
- package/bundle/src/application/sonamu.generated.sso.ts +2 -0
- package/bundle/src/application/sonamu.generated.ts +15 -0
- package/bundle/src/application/token/token.identity.test.ts +20 -0
- package/bundle/src/application/token/token.model.ts +66 -7
- package/bundle/src/application/token/token.types.ts +24 -1
- package/bundle/src/i18n/en.ts +19 -0
- package/bundle/src/i18n/ko.ts +21 -0
- package/bundle/src/i18n/sd.generated.ts +23 -2
- package/bundle/src/migrations/20260807133553_manual__backfill_request_log_cost.ts +16 -8
- package/bundle/src/server-bootstrap.ts +4 -2
- package/bundle/src/server-error-handler.ts +1 -0
- package/bundle/src/sonamu.config.ts +69 -7
- package/bundle/src/startup-migrations.ts +27 -9
- package/bundle/src/testing/global.ts +20 -0
- package/bundle/src/testing/schema-bench.ts +105 -30
- package/bundle/src/testing/test-database-name.ts +2 -0
- package/bundle/src/utils/providers/anthropic/anthropic-constants.ts +8 -0
- package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +41 -6
- package/bundle/src/utils/providers/anthropic/anthropic-quota.ts +7 -3
- package/bundle/src/utils/providers/anthropic/anthropic-thinking.ts +6 -0
- package/bundle/src/utils/providers/anthropic/claude-session.ts +58 -24
- package/bundle/src/utils/providers/anthropic/fence-strip.ts +11 -0
- package/bundle/src/utils/providers/anthropic/stream-json-adapter.ts +110 -45
- package/bundle/src/utils/providers/common/credentials.ts +8 -0
- package/bundle/src/utils/providers/common/effort.ts +9 -2
- package/bundle/src/utils/providers/common/model-cost.test.ts +48 -1
- package/bundle/src/utils/providers/common/model-cost.ts +259 -158
- package/bundle/src/utils/providers/common/provider-dispatcher.ts +98 -2
- package/bundle/src/utils/providers/common/provider-types.ts +46 -3
- package/bundle/src/utils/providers/common/schema-validation.test.ts +5 -1
- package/bundle/src/utils/providers/common/schema-validation.ts +124 -56
- package/bundle/src/utils/providers/common/smooth-weighted-round-robin.ts +4 -0
- package/bundle/src/utils/providers/common/strictifier.ts +185 -59
- package/bundle/src/utils/providers/common/thinking.ts +2 -2
- package/bundle/src/utils/providers/common/ttft.ts +4 -2
- package/bundle/src/utils/providers/grok/__fixtures__/golden-responses-1.0.60.json +164 -0
- package/bundle/src/utils/providers/grok/grok-backend-protocol.test.ts +325 -0
- package/bundle/src/utils/providers/grok/grok-backend-protocol.ts +721 -0
- package/bundle/src/utils/providers/grok/grok-constants.ts +105 -0
- package/bundle/src/utils/providers/grok/grok-direct-client.test.ts +179 -0
- package/bundle/src/utils/providers/grok/grok-direct-client.ts +313 -0
- package/bundle/src/utils/providers/grok/grok-dispatcher.test.ts +1395 -0
- package/bundle/src/utils/providers/grok/grok-dispatcher.ts +2105 -0
- package/bundle/src/utils/providers/grok/grok-headers.test.ts +149 -0
- package/bundle/src/utils/providers/grok/grok-headers.ts +199 -0
- package/bundle/src/utils/providers/grok/grok-media-client.test.ts +446 -0
- package/bundle/src/utils/providers/grok/grok-media-client.ts +703 -0
- package/bundle/src/utils/providers/grok/grok-models.test.ts +96 -0
- package/bundle/src/utils/providers/grok/grok-models.ts +161 -0
- package/bundle/src/utils/providers/grok/grok-oauth.test.ts +406 -0
- package/bundle/src/utils/providers/grok/grok-oauth.ts +771 -0
- package/bundle/src/utils/providers/grok/grok-quota.test.ts +142 -0
- package/bundle/src/utils/providers/grok/grok-quota.ts +198 -0
- package/bundle/src/utils/providers/grok/grok-refresh.test.ts +239 -0
- package/bundle/src/utils/providers/grok/grok-refresh.ts +325 -0
- package/bundle/src/utils/providers/grok/grok-types.test.ts +252 -0
- package/bundle/src/utils/providers/grok/grok-types.ts +374 -0
- package/bundle/src/utils/providers/grok/grok-voice-client.test.ts +321 -0
- package/bundle/src/utils/providers/grok/grok-voice-client.ts +284 -0
- package/bundle/src/utils/providers/grok/index.ts +20 -0
- package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +221 -137
- package/bundle/src/utils/providers/openai/openai-callback-relay.ts +12 -1
- package/bundle/src/utils/providers/openai/openai-constants.ts +2 -0
- package/bundle/src/utils/providers/openai/openai-direct-client.ts +111 -21
- package/bundle/src/utils/providers/openai/openai-dispatcher.ts +322 -169
- package/bundle/src/utils/providers/openai/openai-image-generation.ts +116 -36
- package/bundle/src/utils/providers/openai/openai-oauth.ts +48 -20
- package/bundle/src/utils/providers/openai/openai-quota.ts +77 -46
- package/bundle/src/utils/providers/openai/openai-refresh.ts +42 -18
- package/bundle/src/utils/providers/openai/openai-sse.ts +27 -3
- package/bundle/src/utils/providers/openai/openai-transport-config.ts +2 -0
- package/bundle/src/utils/quiet-hours.ts +12 -1
- package/bundle/src/utils/slack-notify.ts +44 -13
- package/bundle/src/utils/subset-loaders.ts +7 -7
- package/bundle/web-dist/client/assets/clsx-5XM_pHvN.js +1 -0
- package/bundle/web-dist/client/assets/index-Be2qCZmI.css +1 -0
- package/bundle/web-dist/client/assets/index-C96h3feE.js +32 -0
- package/bundle/web-dist/client/assets/logs-DBM6U0QD.js +1 -0
- package/bundle/web-dist/client/assets/monit-BBjXa7vB.js +1 -0
- package/bundle/web-dist/client/assets/routes-Crz_PQzi.js +5 -0
- package/bundle/web-dist/client/assets/{services.generated-NP-ValHd.js → services.generated-B5lc3aIC.js} +5 -5
- package/bundle/web-dist/client/assets/settings-Cdwm3OBB.js +1 -0
- package/bundle/web-dist/client/assets/show-DBUhALT1.js +2 -0
- package/bundle/web-dist/client/assets/tokens-CVQAVJTo.js +1 -0
- package/bundle/web-dist/client/assets/total-cost-MnfKU8IN.js +1 -0
- package/bundle/web-dist/client/assets/use-oauth-login-flow-BfxYI4Oh.js +1 -0
- package/bundle/web-dist/client/assets/use-update-token-mutation-qKBC2sn7.js +1 -0
- package/bundle/web-dist/client/assets/{vendor-tanstack-DJRQAbrY.js → vendor-tanstack-DRPs09ai.js} +1 -1
- package/bundle/web-dist/client/index.html +5 -5
- package/bundle/web-dist/server/assets/clsx-D_N5PN_2.js +16 -0
- package/bundle/web-dist/server/assets/{lazyRouteComponent-CgBdabgd.js → lazyRouteComponent-AKiHfZWp.js} +129 -2
- package/bundle/web-dist/server/assets/{logs-BMyR98rU.js → logs-B7QmGJq3.js} +18 -14
- package/bundle/web-dist/server/assets/{monit-ZPt66W5M.js → monit-DFt7x3bh.js} +13 -12
- package/bundle/web-dist/server/assets/{plus-BZ9I0VgC.js → plus-DaYQRpBt.js} +1 -1
- package/bundle/web-dist/server/assets/{react-dom-Ds75e4Jl.js → react-dom-Cv23mm1K.js} +2 -129
- package/bundle/web-dist/server/assets/{refresh-cw-CztCFis-.js → refresh-cw-BpXNsAy-.js} +1 -1
- package/bundle/web-dist/server/assets/{request-model-DjGldb-h.js → request-model-eHE6YbaF.js} +1 -1
- package/bundle/web-dist/server/assets/{routes-Ct-k7nBA.js → routes-_Y-PJfgO.js} +110 -39
- package/bundle/web-dist/server/assets/{services.generated-BA4AcAf5.js → services.generated-CMJ8AHbO.js} +582 -172
- package/bundle/web-dist/server/assets/{settings-CBUZ47Xx.js → settings-JwJKxn2e.js} +14 -14
- package/bundle/web-dist/server/assets/{show-LSFIzvO2.js → show-BEv6z1v_.js} +90 -60
- package/bundle/web-dist/server/assets/{tokens-DxrBW512.js → tokens-CNT4mI-f.js} +162 -50
- package/bundle/web-dist/server/assets/total-cost-fTE9Xy82.js +18 -0
- package/bundle/web-dist/server/assets/use-oauth-login-flow-jkAkT3X6.js +2345 -0
- package/bundle/web-dist/server/assets/{use-update-token-mutation-pkArIzCP.js → use-update-token-mutation-Sm6kh02m.js} +1 -1
- package/bundle/web-dist/server/entry-server.generated.js +1644 -21655
- package/dist/cli.js +9 -9
- package/package.json +4 -11
- package/postinstall.mjs +12 -0
- package/skills/qgrid/SKILL.md +1 -0
- package/skills/qgrid/references/cli-env-and-server-boot.md +4 -1
- package/skills/qgrid/references/decision-rationale.md +23 -0
- package/skills/qgrid/references/grok-runtime.md +89 -0
- package/skills/qgrid/references/provider-runtime-differences.md +30 -29
- package/skills/qgrid/references/repo-map.md +10 -0
- package/skills/qgrid/references/token-auth-quota-lifecycle.md +56 -3
- package/bundle/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +0 -406
- package/bundle/dist/node_modules/.pnpm/@vitest_expect@4.1.10/node_modules/@vitest/expect/dist/index.js +0 -1507
- package/bundle/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.10/node_modules/@vitest/pretty-format/dist/index.js +0 -887
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js +0 -2756
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/index.js +0 -8
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/utils.js +0 -8
- package/bundle/dist/node_modules/.pnpm/@vitest_snapshot@4.1.10/node_modules/@vitest/snapshot/dist/index.js +0 -922
- package/bundle/dist/node_modules/.pnpm/@vitest_spy@4.1.10/node_modules/@vitest/spy/dist/index.js +0 -386
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +0 -121
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/constants.js +0 -51
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/diff.js +0 -1317
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/display.js +0 -561
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/error.js +0 -40
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/helpers.js +0 -272
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/offset.js +0 -27
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/serialize.js +0 -77
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/source-map.js +0 -381
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/timers.js +0 -51
- package/bundle/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js +0 -2986
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js +0 -10
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js +0 -109
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js +0 -10
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js +0 -10
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js +0 -10
- package/bundle/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +0 -1126
- package/bundle/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -21
- package/bundle/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -432
- package/bundle/dist/node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js +0 -517
- package/bundle/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.js +0 -101
- package/bundle/dist/node_modules/.pnpm/vite@8.0.3_@emnapi_core@1.11.2_@emnapi_runtime@1.11.2_@types_node@25.0.7_esbuild@0.27.4_5b35fc1fb85d2af4d105e0d74f940f50/node_modules/vite/dist/node/module-runner.js +0 -1265
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -9
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js +0 -41
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -19
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +0 -202
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/index.DdgEv5B1.js +0 -46
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +0 -119
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js +0 -3044
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +0 -59
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/index.js +0 -28
- package/bundle/dist/testing/setup-mocks.js +0 -16
- package/bundle/src/testing/setup-mocks.ts +0 -44
- package/bundle/web-dist/client/assets/index-Bw2s88Ot.css +0 -1
- package/bundle/web-dist/client/assets/index-DZwzUfI-.js +0 -106
- package/bundle/web-dist/client/assets/logs-Cog79DU5.js +0 -1
- package/bundle/web-dist/client/assets/monit-2auznBys.js +0 -1
- package/bundle/web-dist/client/assets/routes-B0lTeLK-.js +0 -5
- package/bundle/web-dist/client/assets/settings-D8ZxZGSJ.js +0 -1
- package/bundle/web-dist/client/assets/show-CFSERlnM.js +0 -2
- package/bundle/web-dist/client/assets/tokens-CZXUyI7O.js +0 -1
- package/bundle/web-dist/client/assets/use-oauth-login-flow-hboOs3wG.js +0 -1
- package/bundle/web-dist/client/assets/use-update-token-mutation-BQHS0byG.js +0 -1
- package/bundle/web-dist/server/assets/use-oauth-login-flow-Gn8flMK5.js +0 -178
- package/dist/cli.d.ts +0 -10
- /package/bundle/web-dist/client/assets/{cost-DH2jZbrw.js → cost-DB3HbU7T.js} +0 -0
- /package/bundle/web-dist/client/assets/{plus-B62CuqT8.js → plus-BsQdY7PS.js} +0 -0
- /package/bundle/web-dist/client/assets/{preload-helper-ca-nBW7U.js → preload-helper-DWTEM3RW.js} +0 -0
- /package/bundle/web-dist/client/assets/{refresh-cw-NNcU0Cmq.js → refresh-cw-D9IUmT23.js} +0 -0
- /package/bundle/web-dist/client/assets/{request-model-CojtinqK.js → request-model-Bpp_rkK8.js} +0 -0
- /package/bundle/web-dist/server/assets/{cost-eEHeTRT5.js → cost-BC9yzyA9.js} +0 -0
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @see https://platform.claude.com/docs/en/about-claude/pricing
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { GROK_USD_PER_TICK } from "../grok/grok-constants";
|
|
13
14
|
import { type OpenAIEffort } from "./effort";
|
|
14
15
|
|
|
15
16
|
export interface ModelCosts {
|
|
@@ -52,105 +53,107 @@ const LONG_CONTEXT_272K: NonNullable<ModelCosts["longContext"]> = {
|
|
|
52
53
|
// 미기재 모델은 xhigh 까지만 받는다.
|
|
53
54
|
type OpenAIModelSpec = ModelCosts & { maxEffort?: OpenAIEffort };
|
|
54
55
|
|
|
55
|
-
const OPENAI_COSTS
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
56
|
+
const OPENAI_COSTS = new Map<string, OpenAIModelSpec>(
|
|
57
|
+
Object.entries({
|
|
58
|
+
// GPT-6 Astra: Standard API-equivalent pricing, verified 2026-09-07.
|
|
59
|
+
// Codex subscription catalog supports ultra; the public API lists only through max.
|
|
60
|
+
// @see https://developers.openai.com/api/docs/models/gpt-6-astra
|
|
61
|
+
// @see https://developers.openai.com/api/docs/pricing
|
|
62
|
+
"gpt-6-astra": {
|
|
63
|
+
maxEffort: "ultra",
|
|
64
|
+
inputTokens: 10,
|
|
65
|
+
outputTokens: 50,
|
|
66
|
+
cachedInputTokens: 1,
|
|
67
|
+
cacheCreationInputTokens: 12.5,
|
|
68
|
+
longContext: LONG_CONTEXT_272K,
|
|
69
|
+
},
|
|
70
|
+
// GPT-6.1 Sol (2026-09-29 DevDay 출시): Standard API pricing verified 2026-09-30. GPT-6 Sol 과 같고 cached input 만 절반.
|
|
71
|
+
// Codex 카탈로그(2026-09-30)는 ultra 까지 허용하고 기본 effort 는 low 다(GPT-6 Sol 은 medium).
|
|
72
|
+
// qgrid 의 요청 형태 + codex_cli_rs/0.147.0 헤더로 2026-09-30 구독 경로 라이브 생성 성공.
|
|
73
|
+
// @see https://developers.openai.com/api/docs/models/gpt-6.1-sol
|
|
74
|
+
"gpt-6.1-sol": {
|
|
75
|
+
maxEffort: "ultra",
|
|
76
|
+
inputTokens: 2,
|
|
77
|
+
outputTokens: 10,
|
|
78
|
+
cachedInputTokens: 0.1,
|
|
79
|
+
cacheCreationInputTokens: 2.5,
|
|
80
|
+
longContext: LONG_CONTEXT_272K,
|
|
81
|
+
},
|
|
82
|
+
// GPT-6 Sol, Luna (2026-09-22 출시): Standard API pricing verified 2026-09-23. GPT-5.6 Sol/Luna 의 절반 단가.
|
|
83
|
+
// Codex 카탈로그(2026-09-23)는 Sol 에 ultra, Luna 에 max 까지 허용하고 기본 effort 는 둘 다 medium 이다.
|
|
84
|
+
// @see https://developers.openai.com/api/docs/models/gpt-6-sol
|
|
85
|
+
// @see https://developers.openai.com/api/docs/models/gpt-6-luna
|
|
86
|
+
"gpt-6-sol": {
|
|
87
|
+
maxEffort: "ultra",
|
|
88
|
+
inputTokens: 2,
|
|
89
|
+
outputTokens: 10,
|
|
90
|
+
cachedInputTokens: 0.2,
|
|
91
|
+
cacheCreationInputTokens: 2.5,
|
|
92
|
+
longContext: LONG_CONTEXT_272K,
|
|
93
|
+
},
|
|
94
|
+
"gpt-6-luna": {
|
|
95
|
+
maxEffort: "max",
|
|
96
|
+
inputTokens: 0.1,
|
|
97
|
+
outputTokens: 0.5,
|
|
98
|
+
cachedInputTokens: 0.01,
|
|
99
|
+
cacheCreationInputTokens: 0.125,
|
|
100
|
+
longContext: LONG_CONTEXT_272K,
|
|
101
|
+
},
|
|
102
|
+
// GPT-5.6 Sol, Terra, Luna. cache write 단가는 외부 logger/manual usage 입력을 위해
|
|
103
|
+
// 유지한다. 현재 OpenAI 응답 usage 에 cache write 토큰 필드가 없으면 비용은 0으로 계산된다.
|
|
104
|
+
// @see https://developers.openai.com/api/docs/models/gpt-5.6-sol
|
|
105
|
+
// @see https://developers.openai.com/api/docs/models/gpt-5.6-terra
|
|
106
|
+
// @see https://developers.openai.com/api/docs/models/gpt-5.6-luna
|
|
107
|
+
// Sol promotional rates are available at least through 2026-11-21.
|
|
108
|
+
// No confirmed end date/replacement rate: recheck official pricing instead of auto-reverting.
|
|
109
|
+
"gpt-5.6-sol": {
|
|
110
|
+
maxEffort: "ultra",
|
|
111
|
+
inputTokens: 4,
|
|
112
|
+
outputTokens: 20,
|
|
113
|
+
cachedInputTokens: 0.4,
|
|
114
|
+
cacheCreationInputTokens: 5,
|
|
115
|
+
longContext: LONG_CONTEXT_272K,
|
|
116
|
+
},
|
|
117
|
+
"gpt-5.6-terra": {
|
|
118
|
+
maxEffort: "ultra",
|
|
119
|
+
inputTokens: 2,
|
|
120
|
+
outputTokens: 12,
|
|
121
|
+
cachedInputTokens: 0.2,
|
|
122
|
+
cacheCreationInputTokens: 2.5,
|
|
123
|
+
longContext: LONG_CONTEXT_272K,
|
|
124
|
+
},
|
|
125
|
+
"gpt-5.6-luna": {
|
|
126
|
+
maxEffort: "max",
|
|
127
|
+
inputTokens: 0.2,
|
|
128
|
+
outputTokens: 1.2,
|
|
129
|
+
cachedInputTokens: 0.02,
|
|
130
|
+
cacheCreationInputTokens: 0.25,
|
|
131
|
+
longContext: LONG_CONTEXT_272K,
|
|
132
|
+
},
|
|
133
|
+
// https://openai.com/index/introducing-gpt-5-5/ (2026-04 출시)
|
|
134
|
+
"gpt-5.5": {
|
|
135
|
+
inputTokens: 5,
|
|
136
|
+
outputTokens: 30,
|
|
137
|
+
cachedInputTokens: 0.5,
|
|
138
|
+
longContext: LONG_CONTEXT_272K,
|
|
139
|
+
},
|
|
140
|
+
// 아래 gpt-5.4 / gpt-5.4-mini / gpt-5.3-codex / gpt-5.2 는 qgrid 가 쓰는 ChatGPT 구독 Codex 경로에서
|
|
141
|
+
// 더 이상 제공되지 않는다(5.4 계열은 2026-08-31 retired, 대체 gpt-5.6-terra / gpt-5.6-luna).
|
|
142
|
+
// 과거 request log 재산정(cost_source 없는 legacy 행)에 필요하므로 단가 행은 유지한다.
|
|
143
|
+
// https://openai.com/index/introducing-gpt-5-4/ (2026-03 출시)
|
|
144
|
+
"gpt-5.4": {
|
|
145
|
+
inputTokens: 2.5,
|
|
146
|
+
outputTokens: 15,
|
|
147
|
+
cachedInputTokens: 0.25,
|
|
148
|
+
longContext: LONG_CONTEXT_272K,
|
|
149
|
+
},
|
|
150
|
+
"gpt-5.4-mini": { inputTokens: 0.75, outputTokens: 4.5, cachedInputTokens: 0.075 },
|
|
151
|
+
// gpt-5.2와 동일 단가 (cached = input의 10%)
|
|
152
|
+
"gpt-5.3-codex": { inputTokens: 1.75, outputTokens: 14, cachedInputTokens: 0.175 },
|
|
153
|
+
// https://openai.com/index/introducing-gpt-5-2/ (cached input 90% 할인 명시)
|
|
154
|
+
"gpt-5.2": { inputTokens: 1.75, outputTokens: 14, cachedInputTokens: 0.175 },
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
154
157
|
|
|
155
158
|
// ── Anthropic ───────────────────────────────────────────────────────
|
|
156
159
|
|
|
@@ -159,7 +162,7 @@ function anthropicCosts(
|
|
|
159
162
|
outputTokens: number,
|
|
160
163
|
overrides: Pick<Partial<ModelCosts>, "cachedInputTokens" | "longContext"> = {},
|
|
161
164
|
): ModelCosts {
|
|
162
|
-
|
|
165
|
+
const costs: ModelCosts = {
|
|
163
166
|
inputTokens,
|
|
164
167
|
outputTokens,
|
|
165
168
|
// 표준 cache read 는 base input 의 0.1x. Fable 5.1 처럼 공식 특례 단가가 있으면 override 한다.
|
|
@@ -169,86 +172,172 @@ function anthropicCosts(
|
|
|
169
172
|
cacheCreationInputTokens: inputTokens * 2,
|
|
170
173
|
cacheCreationInputTokens5m: inputTokens * 1.25,
|
|
171
174
|
cacheCreationInputTokens1h: inputTokens * 2,
|
|
172
|
-
// Haiku 5.5 처럼 프롬프트 길이 티어가 있는 모델만 long-context 배율을 가진다.
|
|
173
|
-
...(overrides.longContext ? { longContext: overrides.longContext } : {}),
|
|
174
175
|
};
|
|
176
|
+
|
|
177
|
+
// Haiku 5.5 처럼 프롬프트 길이 티어가 있는 모델만 long-context 배율을 가진다.
|
|
178
|
+
if (overrides.longContext) costs.longContext = overrides.longContext;
|
|
179
|
+
|
|
180
|
+
return costs;
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
// 가격 출처: https://platform.claude.com/docs/en/about-claude/pricing (2026-10-08 확인. 2026-10-07 에 Sonnet 5.5
|
|
178
184
|
// cache read 가 $0.20→$0.10(0.05x)으로 인하됐고, 그 외 기존 모델 단가는 변동 없음)
|
|
179
|
-
const ANTHROPIC_COSTS
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
185
|
+
const ANTHROPIC_COSTS = new Map<string, ModelCosts>(
|
|
186
|
+
Object.entries({
|
|
187
|
+
// Fable 5.1 (2026-09-01 출시): input/output 은 Fable 5 와 같고 cache read 만 0.025x($0.25) 특례.
|
|
188
|
+
// @see https://platform.claude.com/docs/en/models/fable-5-1/overview
|
|
189
|
+
"claude-fable-5-1": anthropicCosts(10, 50, { cachedInputTokens: 0.25 }),
|
|
190
|
+
"claude-fable-5": anthropicCosts(10, 50),
|
|
191
|
+
sonnet: anthropicCosts(3, 15),
|
|
192
|
+
"claude-3-5-haiku": anthropicCosts(0.8, 4),
|
|
193
|
+
"claude-haiku-4-5": anthropicCosts(1, 5),
|
|
194
|
+
"claude-3-5-sonnet": anthropicCosts(3, 15),
|
|
195
|
+
"claude-3-7-sonnet": anthropicCosts(3, 15),
|
|
196
|
+
"claude-sonnet-4": anthropicCosts(3, 15),
|
|
197
|
+
"claude-sonnet-4-5": anthropicCosts(3, 15),
|
|
198
|
+
"claude-sonnet-4-6": anthropicCosts(3, 15),
|
|
199
|
+
"claude-sonnet-4-7": anthropicCosts(3, 15),
|
|
200
|
+
"claude-opus-4": anthropicCosts(15, 75),
|
|
201
|
+
"claude-opus-4-1": anthropicCosts(15, 75),
|
|
202
|
+
"claude-opus-4-5": anthropicCosts(5, 25),
|
|
203
|
+
"claude-opus-4-6": anthropicCosts(5, 25),
|
|
204
|
+
"claude-opus-4-7": anthropicCosts(5, 25),
|
|
205
|
+
"claude-opus-4-8": anthropicCosts(5, 25),
|
|
206
|
+
"claude-opus-5": anthropicCosts(5, 25),
|
|
207
|
+
// Opus 5.5 (2026-09-22 출시): $4/$20. cache read 는 0.05x($0.20) 특례, cache write 는 표준 배율($5/$8).
|
|
208
|
+
// @see https://platform.claude.com/docs/en/models/opus-5-5/overview
|
|
209
|
+
"claude-opus-5-5": anthropicCosts(4, 20, { cachedInputTokens: 0.2 }),
|
|
210
|
+
// Sonnet 5 의 introductory $2/$10 이 정식 단가로 확정됐다. 2026-09-01 에 예정됐던 $3/$15 인상은
|
|
211
|
+
// 취소됐으므로 날짜 분기 없이 고정 단가로 계산한다.
|
|
212
|
+
"claude-sonnet-5": anthropicCosts(2, 10),
|
|
213
|
+
// Sonnet 5.5 (2026-09-28 출시): Sonnet 5 와 같은 $2/$10. cache read 는 출시 시 표준 0.1x($0.20)였다가
|
|
214
|
+
// 2026-10-07 Haiku 5.5 출시와 함께 Opus 5.5 와 같은 0.05x($0.10)로 인하됐다(API 릴리스 노트). 비용은 요청 시점
|
|
215
|
+
// 단가로 기록되므로 날짜 분기 없이 현행 단가만 둔다. cache write 는 표준 배율($2.50/$4).
|
|
216
|
+
// @see https://platform.claude.com/docs/en/release-notes/overview (2026-10-07)
|
|
217
|
+
"claude-sonnet-5-5": anthropicCosts(2, 10, { cachedInputTokens: 0.1 }),
|
|
218
|
+
// Haiku 5.5 (2026-10-07 출시): 프롬프트 길이 티어 단가. 100K 이하 $0.10/$0.50, cache read 0.1x($0.01),
|
|
219
|
+
// cache write 5m $0.125 / 1h $0.20. 입력이 100K 를 넘으면 input/cache read/cache write/output 모두 5x
|
|
220
|
+
// ($0.50/$0.05/$0.625·$1/$2.50)가 요청 전체에 적용된다. 1M 컨텍스트 모델 중 유일하게 길이별 단가를 쓴다.
|
|
221
|
+
// @see https://platform.claude.com/docs/en/models/haiku-5-5/overview
|
|
222
|
+
"claude-haiku-5-5": anthropicCosts(0.1, 0.5, {
|
|
223
|
+
longContext: {
|
|
224
|
+
threshold: 100_000,
|
|
225
|
+
inputMultiplier: 5,
|
|
226
|
+
cachedInputMultiplier: 5,
|
|
227
|
+
outputMultiplier: 5,
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
222
230
|
}),
|
|
223
|
-
|
|
231
|
+
);
|
|
224
232
|
|
|
225
233
|
// gpt-5.3-codex-spark 는 research preview 로 공식 token 단가가 아직 final 이 아니다.
|
|
226
234
|
// 지원 타입은 유지하되, 공식 단가가 공개될 때까지 아래 generic estimate 로 계산한다.
|
|
227
235
|
// @see https://help.openai.com/en/articles/20001106-codex-rate-card
|
|
228
236
|
const DEFAULT_COSTS: ModelCosts = { inputTokens: 3, outputTokens: 15, cachedInputTokens: 0.3 };
|
|
229
237
|
|
|
238
|
+
// -- Grok (xAI) --
|
|
239
|
+
//
|
|
240
|
+
// Fallback only. Grok chat, image and video responses report `usage.cost_in_usd_ticks`, which is
|
|
241
|
+
// authoritative (costSource "provider"); these rows price a response that omitted it.
|
|
242
|
+
// Source: api.x.ai/v1/language-models and /image-generation-models read with the subscription JWT
|
|
243
|
+
// in the 2026-10-16 live probe. One tick is 1e-10 USD (grok-4.7 lists 20000/5000/60000 ticks per
|
|
244
|
+
// input/cached/output token against the public $2/$0.50/$6 per million).
|
|
245
|
+
const GROK_TICKS_PER_USD = Math.round(1 / GROK_USD_PER_TICK);
|
|
246
|
+
|
|
247
|
+
/** USD for a provider-reported `cost_in_usd_ticks` amount. */
|
|
248
|
+
export function usdFromGrokTicks(ticks: number): number {
|
|
249
|
+
return ticks / GROK_TICKS_PER_USD;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function grokTokenCosts(input: number, cached: number, output: number): ModelCosts {
|
|
253
|
+
// ticks per token -> USD per 1M tokens.
|
|
254
|
+
const perMillion = (ticks: number) => (ticks * 1_000_000) / GROK_TICKS_PER_USD;
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
inputTokens: perMillion(input),
|
|
258
|
+
cachedInputTokens: perMillion(cached),
|
|
259
|
+
outputTokens: perMillion(output),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const GROK_COSTS = new Map<string, ModelCosts>(
|
|
264
|
+
Object.entries({
|
|
265
|
+
"grok-4.7": grokTokenCosts(20_000, 5_000, 60_000),
|
|
266
|
+
"grok-4.6": grokTokenCosts(20_000, 5_000, 60_000),
|
|
267
|
+
"grok-4.5": grokTokenCosts(20_000, 5_000, 60_000),
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
// Ticks per generated image at the default 1k resolution (the probe's quality 1k image cost exactly
|
|
272
|
+
// this amount). Unlisted image models have no estimate.
|
|
273
|
+
const GROK_IMAGE_PRICE_TICKS = new Map<string, number>(
|
|
274
|
+
Object.entries({
|
|
275
|
+
"grok-imagine-image-quality": 500_000_000,
|
|
276
|
+
}),
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
export interface GrokMediaCost {
|
|
280
|
+
costUsd: number;
|
|
281
|
+
costSource: "provider" | "pricing_table";
|
|
282
|
+
/** Ticks reported by xAI, or the catalog-price estimate in ticks. */
|
|
283
|
+
ticks: number;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Image cost: the reported ticks when present, otherwise the per-image catalog price times the
|
|
288
|
+
* image count. Undefined when neither is known, so callers store an unknown cost, not a guess.
|
|
289
|
+
*/
|
|
290
|
+
export function grokImageCost(
|
|
291
|
+
model: string,
|
|
292
|
+
imageCount: number,
|
|
293
|
+
reportedTicks?: number,
|
|
294
|
+
): GrokMediaCost | undefined {
|
|
295
|
+
if (reportedTicks !== undefined) return grokReportedCost(reportedTicks);
|
|
296
|
+
const perImage = GROK_IMAGE_PRICE_TICKS.get(model.split("/").pop() ?? model);
|
|
297
|
+
|
|
298
|
+
if (perImage === undefined) return undefined;
|
|
299
|
+
const ticks = perImage * imageCount;
|
|
300
|
+
|
|
301
|
+
return { costUsd: usdFromGrokTicks(ticks), costSource: "pricing_table", ticks };
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Video/voice cost: only a provider-reported amount; there is no catalog estimate. */
|
|
305
|
+
export function grokReportedCost(reportedTicks: number | undefined): GrokMediaCost | undefined {
|
|
306
|
+
return reportedTicks === undefined
|
|
307
|
+
? undefined
|
|
308
|
+
: { costUsd: usdFromGrokTicks(reportedTicks), costSource: "provider", ticks: reportedTicks };
|
|
309
|
+
}
|
|
310
|
+
|
|
230
311
|
/** Codex 백엔드가 이 모델에 허용하는 최대 effort. 카탈로그에 없는 모델은 xhigh 까지다. */
|
|
231
312
|
export function openaiModelMaxEffort(model: string): OpenAIEffort {
|
|
232
|
-
return OPENAI_COSTS
|
|
313
|
+
return OPENAI_COSTS.get(model)?.maxEffort ?? "xhigh";
|
|
233
314
|
}
|
|
234
315
|
|
|
235
316
|
export function getModelCosts(model: string): ModelCosts {
|
|
236
317
|
const normalizedModel = (model.split("/").pop() ?? model).replace(/\[1m\]$/i, "");
|
|
237
|
-
|
|
318
|
+
|
|
319
|
+
return (
|
|
320
|
+
OPENAI_COSTS.get(normalizedModel) ??
|
|
321
|
+
ANTHROPIC_COSTS.get(normalizedModel) ??
|
|
322
|
+
GROK_COSTS.get(normalizedModel) ??
|
|
323
|
+
DEFAULT_COSTS
|
|
324
|
+
);
|
|
238
325
|
}
|
|
239
326
|
|
|
240
327
|
// Verified Fast API rates for the currently served Codex models (2026-10-16).
|
|
241
328
|
// Applies to all token categories and long context; not the 2.5x subscription quota multiplier.
|
|
242
329
|
// https://developers.openai.com/api/docs/pricing
|
|
243
|
-
const OPENAI_FAST_MULTIPLIERS
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
330
|
+
const OPENAI_FAST_MULTIPLIERS = new Map<string, number>(
|
|
331
|
+
Object.entries({
|
|
332
|
+
"gpt-6-astra": 2,
|
|
333
|
+
"gpt-6.1-sol": 2,
|
|
334
|
+
"gpt-6-sol": 2,
|
|
335
|
+
"gpt-6-luna": 2,
|
|
336
|
+
"gpt-5.6-sol": 2,
|
|
337
|
+
"gpt-5.6-terra": 2,
|
|
338
|
+
"gpt-5.6-luna": 2,
|
|
339
|
+
}),
|
|
340
|
+
);
|
|
252
341
|
|
|
253
342
|
export function calculateCostUsd(
|
|
254
343
|
model: string,
|
|
@@ -266,17 +355,22 @@ export function calculateCostUsd(
|
|
|
266
355
|
const cachedInput = usage.cachedInputTokens ?? 0;
|
|
267
356
|
const cacheCreationInput5m = Math.max(usage.cacheCreationInputTokens5m ?? 0, 0);
|
|
268
357
|
const cacheCreationInput1h = Math.max(usage.cacheCreationInputTokens1h ?? 0, 0);
|
|
358
|
+
|
|
269
359
|
const cacheCreationInput = Math.max(
|
|
270
360
|
usage.cacheCreationInputTokens ?? 0,
|
|
271
361
|
cacheCreationInput5m + cacheCreationInput1h,
|
|
272
362
|
);
|
|
363
|
+
|
|
273
364
|
const classifiedCacheCreationInput5m = Math.min(cacheCreationInput5m, cacheCreationInput);
|
|
365
|
+
|
|
274
366
|
const classifiedCacheCreationInput1h = Math.min(
|
|
275
367
|
cacheCreationInput1h,
|
|
276
368
|
cacheCreationInput - classifiedCacheCreationInput5m,
|
|
277
369
|
);
|
|
370
|
+
|
|
278
371
|
const unclassifiedCacheCreationInput =
|
|
279
372
|
cacheCreationInput - classifiedCacheCreationInput5m - classifiedCacheCreationInput1h;
|
|
373
|
+
|
|
280
374
|
const nonCachedInput = Math.max(usage.inputTokens - cachedInput - cacheCreationInput, 0);
|
|
281
375
|
|
|
282
376
|
// long-context 할증: 전체 입력(input_tokens, cache 포함)이 threshold 초과 시 요청 전체에 배율 적용
|
|
@@ -284,15 +378,19 @@ export function calculateCostUsd(
|
|
|
284
378
|
const isLongContext = lc !== undefined && usage.inputTokens > lc.threshold;
|
|
285
379
|
const inputRate = costs.inputTokens * (isLongContext ? lc.inputMultiplier : 1);
|
|
286
380
|
const cachedRate = costs.cachedInputTokens * (isLongContext ? lc.cachedInputMultiplier : 1);
|
|
381
|
+
|
|
287
382
|
const cacheCreationFallbackRate =
|
|
288
383
|
(costs.cacheCreationInputTokens ?? costs.inputTokens) *
|
|
289
384
|
(isLongContext ? lc.inputMultiplier : 1);
|
|
385
|
+
|
|
290
386
|
const cacheCreation5mRate =
|
|
291
387
|
(costs.cacheCreationInputTokens5m ?? costs.cacheCreationInputTokens ?? costs.inputTokens) *
|
|
292
388
|
(isLongContext ? lc.inputMultiplier : 1);
|
|
389
|
+
|
|
293
390
|
const cacheCreation1hRate =
|
|
294
391
|
(costs.cacheCreationInputTokens1h ?? costs.cacheCreationInputTokens ?? costs.inputTokens) *
|
|
295
392
|
(isLongContext ? lc.inputMultiplier : 1);
|
|
393
|
+
|
|
296
394
|
const outputRate = costs.outputTokens * (isLongContext ? lc.outputMultiplier : 1);
|
|
297
395
|
|
|
298
396
|
const standardCost =
|
|
@@ -302,8 +400,11 @@ export function calculateCostUsd(
|
|
|
302
400
|
(unclassifiedCacheCreationInput / 1_000_000) * cacheCreationFallbackRate +
|
|
303
401
|
(classifiedCacheCreationInput5m / 1_000_000) * cacheCreation5mRate +
|
|
304
402
|
(classifiedCacheCreationInput1h / 1_000_000) * cacheCreation1hRate;
|
|
403
|
+
|
|
305
404
|
const normalizedModel = model.split("/").pop() ?? model;
|
|
405
|
+
|
|
306
406
|
return (
|
|
307
|
-
standardCost *
|
|
407
|
+
standardCost *
|
|
408
|
+
(serviceTier === "fast" ? (OPENAI_FAST_MULTIPLIERS.get(normalizedModel) ?? 1) : 1)
|
|
308
409
|
);
|
|
309
410
|
}
|