@cartanova/qgrid-cli 2.10.9 → 2.11.0
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 +22 -20
- package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +43 -34
- 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 -69
- package/bundle/dist/application/request-log/request-log.types.js +8 -2
- 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 +40 -16
- package/bundle/dist/application/sonamu.generated.sso.js +2 -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 +2 -1
- package/bundle/dist/migrations/20260807133553_manual__backfill_request_log_cost.js +8 -6
- package/bundle/dist/migrations/20261018215031_alter_request_logs_add1_alter1.js +15 -0
- 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 +33 -0
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +87 -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.entity.json +8 -0
- package/bundle/src/application/request-log/request-log.model.test.ts +111 -4
- package/bundle/src/application/request-log/request-log.model.ts +279 -145
- package/bundle/src/application/request-log/request-log.types.ts +17 -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 +135 -0
- package/bundle/src/application/sonamu.generated.sso.ts +3 -0
- package/bundle/src/application/sonamu.generated.ts +29 -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 +24 -2
- package/bundle/src/migrations/20260807133553_manual__backfill_request_log_cost.ts +16 -8
- package/bundle/src/migrations/20261018215031_alter_request_logs_add1_alter1.ts +15 -0
- 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-BA7uQ-6c.js +31 -0
- package/bundle/web-dist/client/assets/index-Be2qCZmI.css +1 -0
- package/bundle/web-dist/client/assets/logs-C47OJGEI.js +1 -0
- package/bundle/web-dist/client/assets/monit-BS9no0dU.js +4 -0
- package/bundle/web-dist/client/assets/plus-sdACTfH0.js +1 -0
- package/bundle/web-dist/client/assets/refresh-cw-CY8o_1cT.js +1 -0
- package/bundle/web-dist/client/assets/request-model-BRtFuZvj.js +1 -0
- package/bundle/web-dist/client/assets/routes-kqgkUxE8.js +5 -0
- package/bundle/web-dist/client/assets/{services.generated-BsieU37H.js → services.generated-CefiDXEv.js} +5 -5
- package/bundle/web-dist/client/assets/settings-DNDvFGSw.js +1 -0
- package/bundle/web-dist/client/assets/show-u8Np69q3.js +2 -0
- package/bundle/web-dist/client/assets/tokens-QvP410NW.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-Bzdh28Ws.js +1 -0
- package/bundle/web-dist/client/assets/use-update-token-mutation-CfJKaxmR.js +1 -0
- package/bundle/web-dist/client/assets/vendor-react-CUFFrVN9.js +244 -0
- package/bundle/web-dist/client/assets/vendor-tanstack-Bf_jag9G.js +1 -0
- package/bundle/web-dist/client/index.html +6 -6
- package/bundle/web-dist/server/assets/clsx-D_N5PN_2.js +16 -0
- package/bundle/web-dist/server/assets/{lazyRouteComponent-Dtd0NR4r.js → lazyRouteComponent-D8iTIHyn.js} +129 -2
- package/bundle/web-dist/server/assets/logs-B3OTd9hy.js +825 -0
- package/bundle/web-dist/server/assets/{monit-DvzribSE.js → monit-B2hqorPe.js} +385 -126
- package/bundle/web-dist/server/assets/plus-DwG7h9kq.js +28 -0
- package/bundle/web-dist/server/assets/{react-dom-B4a6-uuR.js → react-dom-BIYQzBqG.js} +2 -129
- package/bundle/web-dist/server/assets/refresh-cw-mMBkwOq0.js +44 -0
- package/bundle/web-dist/server/assets/{request-model-CbqfnQOJ.js → request-model-I6OdODSH.js} +15 -6
- package/bundle/web-dist/server/assets/{routes-BAPWTizT.js → routes-B95YlUv2.js} +760 -213
- package/bundle/web-dist/server/assets/{services.generated-CEbGjsI0.js → services.generated-DQATJ6qf.js} +12821 -12194
- package/bundle/web-dist/server/assets/settings-C3gbGk0m.js +830 -0
- package/bundle/web-dist/server/assets/{show-CxVZTAdv.js → show-Bxaj3rhH.js} +1355 -419
- package/bundle/web-dist/server/assets/tokens-CZjH3cB7.js +1038 -0
- package/bundle/web-dist/server/assets/total-cost-fTE9Xy82.js +18 -0
- package/bundle/web-dist/server/assets/use-oauth-login-flow-CKDHgc3U.js +2379 -0
- package/bundle/web-dist/server/assets/{use-update-token-mutation-CfYmk_4_.js → use-update-token-mutation-BEbgOzaa.js} +1 -1
- package/bundle/web-dist/server/entry-server.generated.js +4303 -22810
- 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 +24 -1
- 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/request-log-run-lifecycle.md +1 -1
- package/skills/qgrid/references/sonamu-api-web-flow.md +1 -1
- 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-CrXKu_J8.js +0 -106
- package/bundle/web-dist/client/assets/logs-B2SmWJXA.js +0 -1
- package/bundle/web-dist/client/assets/monit-D-JwXXoA.js +0 -1
- package/bundle/web-dist/client/assets/plus-B62CuqT8.js +0 -1
- package/bundle/web-dist/client/assets/refresh-cw-NNcU0Cmq.js +0 -1
- package/bundle/web-dist/client/assets/request-model-CojtinqK.js +0 -1
- package/bundle/web-dist/client/assets/routes-C5r4gTvY.js +0 -5
- package/bundle/web-dist/client/assets/settings-D3tDSAck.js +0 -1
- package/bundle/web-dist/client/assets/show-Cah_kUKC.js +0 -2
- package/bundle/web-dist/client/assets/tokens-DU2Iyxxd.js +0 -1
- package/bundle/web-dist/client/assets/use-oauth-login-flow-D0UaR9_e.js +0 -1
- package/bundle/web-dist/client/assets/use-update-token-mutation-DAq0F8p-.js +0 -1
- package/bundle/web-dist/client/assets/vendor-react-DH4kUfK2.js +0 -9
- package/bundle/web-dist/client/assets/vendor-tanstack-DJRQAbrY.js +0 -1
- package/bundle/web-dist/server/assets/logs-l91avYif.js +0 -509
- package/bundle/web-dist/server/assets/plus-KZrECewT.js +0 -19
- package/bundle/web-dist/server/assets/refresh-cw-BND93JrF.js +0 -23
- package/bundle/web-dist/server/assets/settings-BZR5HSAL.js +0 -461
- package/bundle/web-dist/server/assets/tokens-D1hb4eKk.js +0 -448
- package/bundle/web-dist/server/assets/use-oauth-login-flow-Cvdy0zF8.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/{preload-helper-ca-nBW7U.js → preload-helper-DWTEM3RW.js} +0 -0
- /package/bundle/web-dist/server/assets/{cost-eEHeTRT5.js → cost-BC9yzyA9.js} +0 -0
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
// ─── Query ───
|
|
4
4
|
|
|
5
5
|
export const Effort = z.enum(["low", "medium", "high"]);
|
|
6
|
+
|
|
6
7
|
export type Effort = z.infer<typeof Effort>;
|
|
7
8
|
|
|
8
9
|
export const QgridTool = z.object({
|
|
@@ -10,6 +11,7 @@ export const QgridTool = z.object({
|
|
|
10
11
|
description: z.string().optional(),
|
|
11
12
|
inputSchema: z.unknown(),
|
|
12
13
|
});
|
|
14
|
+
|
|
13
15
|
export type QgridTool = z.infer<typeof QgridTool>;
|
|
14
16
|
|
|
15
17
|
// Observed image response values, distinct from requested generation hints.
|
|
@@ -40,6 +42,7 @@ export const ImageGenerationMetadata = z.object({
|
|
|
40
42
|
})
|
|
41
43
|
.optional(),
|
|
42
44
|
});
|
|
45
|
+
|
|
43
46
|
export type ImageGenerationMetadata = z.infer<typeof ImageGenerationMetadata>;
|
|
44
47
|
|
|
45
48
|
export const QgridContent = z.discriminatedUnion("type", [
|
|
@@ -62,21 +65,27 @@ export const QgridContent = z.discriminatedUnion("type", [
|
|
|
62
65
|
generation: ImageGenerationMetadata.optional(),
|
|
63
66
|
}),
|
|
64
67
|
]);
|
|
68
|
+
|
|
65
69
|
export type QgridContent = z.infer<typeof QgridContent>;
|
|
66
70
|
|
|
67
71
|
export const FinishReason = z.enum(["stop", "tool-calls"]);
|
|
72
|
+
|
|
68
73
|
export type FinishReason = z.infer<typeof FinishReason>;
|
|
69
74
|
|
|
70
75
|
export const Verbosity = z.enum(["low", "medium", "high"]);
|
|
76
|
+
|
|
71
77
|
export type Verbosity = z.infer<typeof Verbosity>;
|
|
72
78
|
|
|
73
79
|
export const ReasoningSummary = z.enum(["auto", "concise", "detailed", "none"]);
|
|
80
|
+
|
|
74
81
|
export type ReasoningSummary = z.infer<typeof ReasoningSummary>;
|
|
75
82
|
|
|
76
83
|
export const ServiceTier = z.enum(["fast", "flex"]);
|
|
84
|
+
|
|
77
85
|
export type ServiceTier = z.infer<typeof ServiceTier>;
|
|
78
86
|
|
|
79
87
|
export const ImageGenerationQuality = z.enum(["low", "medium", "high"]);
|
|
88
|
+
|
|
80
89
|
export type ImageGenerationQuality = z.infer<typeof ImageGenerationQuality>;
|
|
81
90
|
|
|
82
91
|
// Subscription-backend hints, not public Images API resolution guarantees.
|
|
@@ -90,6 +99,7 @@ export const ImageGenerationSize = z.union([
|
|
|
90
99
|
"Image dimensions must be positive safe integers",
|
|
91
100
|
),
|
|
92
101
|
]);
|
|
102
|
+
|
|
93
103
|
export type ImageGenerationSize = z.infer<typeof ImageGenerationSize>;
|
|
94
104
|
|
|
95
105
|
export const ImageGenerationOptions = z
|
|
@@ -106,6 +116,7 @@ export const ImageGenerationOptions = z
|
|
|
106
116
|
options.outputFormat === "png",
|
|
107
117
|
{ message: "Transparent image generation only supports PNG output", path: ["outputFormat"] },
|
|
108
118
|
);
|
|
119
|
+
|
|
109
120
|
export type ImageGenerationOptions = z.infer<typeof ImageGenerationOptions>;
|
|
110
121
|
|
|
111
122
|
export const QgridInputPart = z.discriminatedUnion("type", [
|
|
@@ -119,6 +130,7 @@ export const QgridInputPart = z.discriminatedUnion("type", [
|
|
|
119
130
|
url: z.string(),
|
|
120
131
|
}),
|
|
121
132
|
]);
|
|
133
|
+
|
|
122
134
|
export type QgridInputPart = z.infer<typeof QgridInputPart>;
|
|
123
135
|
|
|
124
136
|
export const MAX_QUERY_TIMEOUT_MS = 30 * 60_000;
|
|
@@ -135,6 +147,7 @@ export const QgridThreadCoord = z.object({
|
|
|
135
147
|
epoch: z.number(), // worker spawn 카운터. restart 로 thread 증발 감지
|
|
136
148
|
systemHash: z.string(), // system_prompt 해시. 다른 대화 오접속 방지
|
|
137
149
|
});
|
|
150
|
+
|
|
138
151
|
export type QgridThreadCoord = z.infer<typeof QgridThreadCoord>;
|
|
139
152
|
|
|
140
153
|
export const QgridRunContext = z.object({
|
|
@@ -142,6 +155,7 @@ export const QgridRunContext = z.object({
|
|
|
142
155
|
requestLogId: z.number().optional(),
|
|
143
156
|
threadCoord: QgridThreadCoord.optional(),
|
|
144
157
|
});
|
|
158
|
+
|
|
145
159
|
export type QgridRunContext = z.infer<typeof QgridRunContext>;
|
|
146
160
|
|
|
147
161
|
export const QgridToolResultInput = z.object({
|
|
@@ -150,8 +164,37 @@ export const QgridToolResultInput = z.object({
|
|
|
150
164
|
output: z.string(),
|
|
151
165
|
isError: z.boolean().optional(),
|
|
152
166
|
});
|
|
167
|
+
|
|
153
168
|
export type QgridToolResultInput = z.infer<typeof QgridToolResultInput>;
|
|
154
169
|
|
|
170
|
+
// Opaque per-provider namespaces forwarded to the dispatcher. Only grok/* models read `xai`;
|
|
171
|
+
// other providers ignore it (the AI SDK already warns and drops it for non-grok ids).
|
|
172
|
+
export const XaiQueryProviderOptions = z.object({
|
|
173
|
+
serviceTier: z.enum(["default", "priority"]).optional(),
|
|
174
|
+
parallelToolCalls: z.boolean().optional(),
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export type XaiQueryProviderOptions = z.infer<typeof XaiQueryProviderOptions>;
|
|
178
|
+
|
|
179
|
+
export const QueryProviderOptions = z.object({
|
|
180
|
+
xai: XaiQueryProviderOptions.optional(),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export type QueryProviderOptions = z.infer<typeof QueryProviderOptions>;
|
|
184
|
+
|
|
185
|
+
export const XaiProviderMetadata = z.object({
|
|
186
|
+
costInUsdTicks: z.number().optional(),
|
|
187
|
+
contextWindow: z.number().optional(),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export type XaiProviderMetadata = z.infer<typeof XaiProviderMetadata>;
|
|
191
|
+
|
|
192
|
+
export const QueryProviderMetadata = z.object({
|
|
193
|
+
xai: XaiProviderMetadata.optional(),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export type QueryProviderMetadata = z.infer<typeof QueryProviderMetadata>;
|
|
197
|
+
|
|
155
198
|
export const QueryInput = z.looseObject({
|
|
156
199
|
system: z.string().optional(),
|
|
157
200
|
prompt: z.string(),
|
|
@@ -183,7 +226,9 @@ export const QueryInput = z.looseObject({
|
|
|
183
226
|
imageGeneration: z.union([z.boolean(), z.literal("auto")]).optional(),
|
|
184
227
|
// qgrid 가격 추정 및 Codex 이미지 요청 힌트. 이미지 모델은 gpt-image-2 로 고정 가정한다.
|
|
185
228
|
imageGenerationOptions: ImageGenerationOptions.optional(),
|
|
229
|
+
providerOptions: QueryProviderOptions.optional(),
|
|
186
230
|
});
|
|
231
|
+
|
|
187
232
|
export type QueryInput = z.infer<typeof QueryInput>;
|
|
188
233
|
|
|
189
234
|
export const ModelFallback = z.object({
|
|
@@ -193,9 +238,11 @@ export const ModelFallback = z.object({
|
|
|
193
238
|
category: z.string().optional(),
|
|
194
239
|
explanation: z.string().optional(),
|
|
195
240
|
});
|
|
241
|
+
|
|
196
242
|
export type ModelFallback = z.infer<typeof ModelFallback>;
|
|
197
243
|
|
|
198
244
|
export const CostSource = z.enum(["provider", "pricing_table", "mixed"]);
|
|
245
|
+
|
|
199
246
|
export type CostSource = z.infer<typeof CostSource>;
|
|
200
247
|
|
|
201
248
|
export const QueryOutput = z.object({
|
|
@@ -220,8 +267,10 @@ export const QueryOutput = z.object({
|
|
|
220
267
|
ttftMs: z.number(),
|
|
221
268
|
costUsd: z.number(),
|
|
222
269
|
costSource: CostSource,
|
|
270
|
+
providerMetadata: QueryProviderMetadata.optional(),
|
|
223
271
|
runContext: QgridRunContext.optional(),
|
|
224
272
|
});
|
|
273
|
+
|
|
225
274
|
export type QueryOutput = z.infer<typeof QueryOutput>;
|
|
226
275
|
|
|
227
276
|
// ─── Stream Events ───
|
|
@@ -254,13 +303,255 @@ export const StreamEvents = z.object({
|
|
|
254
303
|
ttftMs: z.number(),
|
|
255
304
|
costUsd: z.number(),
|
|
256
305
|
costSource: CostSource,
|
|
306
|
+
providerMetadata: QueryProviderMetadata.optional(),
|
|
257
307
|
content: z.array(QgridContent),
|
|
258
308
|
runContext: QgridRunContext.optional(),
|
|
259
309
|
}),
|
|
260
310
|
error: z.object({ message: z.string() }),
|
|
261
311
|
});
|
|
312
|
+
|
|
262
313
|
export type StreamEvents = z.infer<typeof StreamEvents>;
|
|
263
314
|
|
|
315
|
+
// --- Grok media and voice ---
|
|
316
|
+
|
|
317
|
+
const MiB = 1024 * 1024;
|
|
318
|
+
|
|
319
|
+
// Fastify bodyLimit for every JSON request; sonamu.config.ts reads it from here.
|
|
320
|
+
export const REQUEST_BODY_LIMIT_BYTES = 10 * MiB;
|
|
321
|
+
|
|
322
|
+
// Media rides inside that JSON body as base64 (4 chars per 3 bytes), so a 10 MiB body carries at
|
|
323
|
+
// most 10 MiB x 3/4 = 7.5 MiB of decoded bytes; 0.5 MiB is left for the prompt, options and JSON
|
|
324
|
+
// framing. The same budget bounds the audio clip, each inline image, and the sum of a request's
|
|
325
|
+
// inline images, so every request the schema accepts also fits the transport.
|
|
326
|
+
export const MEDIA_MAX_INLINE_BYTES = 7 * MiB;
|
|
327
|
+
const MEDIA_MAX_INLINE_LABEL = `${MEDIA_MAX_INLINE_BYTES / MiB} MiB`;
|
|
328
|
+
export const MEDIA_MAX_REFERENCE_IMAGES = 5;
|
|
329
|
+
|
|
330
|
+
const IMAGE_DATA_URL = /^data:(image\/(?:png|jpeg|webp));base64,([A-Za-z0-9+/]*={0,2})$/;
|
|
331
|
+
const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
332
|
+
|
|
333
|
+
function base64DecodedBytes(data: string): number {
|
|
334
|
+
const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
|
|
335
|
+
|
|
336
|
+
return Math.floor((data.length * 3) / 4) - padding;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Decoded bytes of the inline (data URL) images among `refs`; https URLs cost nothing here. */
|
|
340
|
+
function inlineImageBytes(refs: ReadonlyArray<string | undefined>): number {
|
|
341
|
+
let total = 0;
|
|
342
|
+
|
|
343
|
+
for (const ref of refs) {
|
|
344
|
+
const match = ref === undefined ? null : IMAGE_DATA_URL.exec(ref);
|
|
345
|
+
|
|
346
|
+
if (match) total += base64DecodedBytes(match[2]!);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return total;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const INLINE_IMAGES_TOTAL_MESSAGE = `inline images exceed ${MEDIA_MAX_INLINE_LABEL} in total`;
|
|
353
|
+
|
|
354
|
+
function isHttpsUrl(value: string): boolean {
|
|
355
|
+
try {
|
|
356
|
+
return new URL(value).protocol === "https:";
|
|
357
|
+
} catch {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// An https URL (fetched by xAI, never by qgrid) or a base64 image data URL within
|
|
363
|
+
// MEDIA_MAX_INLINE_BYTES.
|
|
364
|
+
export const MediaImageRef = z
|
|
365
|
+
.string()
|
|
366
|
+
.min(1)
|
|
367
|
+
.superRefine((value, ctx) => {
|
|
368
|
+
if (value.startsWith("data:")) {
|
|
369
|
+
const match = IMAGE_DATA_URL.exec(value);
|
|
370
|
+
|
|
371
|
+
if (!match || match[2]!.length % 4 !== 0) {
|
|
372
|
+
ctx.addIssue({
|
|
373
|
+
code: "custom",
|
|
374
|
+
message: "image data URLs must be base64 image/png, image/jpeg or image/webp",
|
|
375
|
+
});
|
|
376
|
+
} else if (base64DecodedBytes(match[2]!) > MEDIA_MAX_INLINE_BYTES) {
|
|
377
|
+
ctx.addIssue({
|
|
378
|
+
code: "custom",
|
|
379
|
+
message: `image data URL exceeds ${MEDIA_MAX_INLINE_LABEL}`,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (!isHttpsUrl(value)) {
|
|
387
|
+
ctx.addIssue({ code: "custom", message: "image URLs must use https or a data URL" });
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const GrokModelId = z.string().regex(/^grok\/[A-Za-z0-9._-]+$/, "model must be grok/<id>");
|
|
392
|
+
|
|
393
|
+
const MediaCallOptions = {
|
|
394
|
+
// Exact token address (grok/<name>), same contract as QueryInput.tokenName.
|
|
395
|
+
tokenName: z.string().optional(),
|
|
396
|
+
projectName: z.string().optional(),
|
|
397
|
+
// false writes no request log, as for query.
|
|
398
|
+
logger: z.boolean().optional(),
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export const GenerateImagesInput = z
|
|
402
|
+
.object({
|
|
403
|
+
model: GrokModelId,
|
|
404
|
+
prompt: z.string().min(1),
|
|
405
|
+
n: z.number().int().min(1).max(3).optional(),
|
|
406
|
+
aspectRatio: z.string().min(1).max(16).optional(),
|
|
407
|
+
resolution: z.string().min(1).max(16).optional(),
|
|
408
|
+
quality: z.string().min(1).max(16).optional(),
|
|
409
|
+
outputFormat: z.enum(["png", "jpeg", "webp"]).optional(),
|
|
410
|
+
// Present: /images/edits with these references; absent: /images/generations.
|
|
411
|
+
referenceImages: z.array(MediaImageRef).min(1).max(MEDIA_MAX_REFERENCE_IMAGES).optional(),
|
|
412
|
+
...MediaCallOptions,
|
|
413
|
+
})
|
|
414
|
+
.refine((input) => inlineImageBytes(input.referenceImages ?? []) <= MEDIA_MAX_INLINE_BYTES, {
|
|
415
|
+
message: INLINE_IMAGES_TOTAL_MESSAGE,
|
|
416
|
+
path: ["referenceImages"],
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
export type GenerateImagesInput = z.infer<typeof GenerateImagesInput>;
|
|
420
|
+
|
|
421
|
+
export const MediaCostSource = z.enum(["provider", "pricing_table"]);
|
|
422
|
+
|
|
423
|
+
export type MediaCostSource = z.infer<typeof MediaCostSource>;
|
|
424
|
+
|
|
425
|
+
export const GenerateImagesOutput = z.object({
|
|
426
|
+
requestLogId: z.number().optional(),
|
|
427
|
+
model: z.string(),
|
|
428
|
+
tokenName: z.string(),
|
|
429
|
+
images: z.array(
|
|
430
|
+
z.object({
|
|
431
|
+
b64: z.string(),
|
|
432
|
+
mimeType: z.string(),
|
|
433
|
+
revisedPrompt: z.string().optional(),
|
|
434
|
+
}),
|
|
435
|
+
),
|
|
436
|
+
usage: z.object({
|
|
437
|
+
imageCount: z.number(),
|
|
438
|
+
costInUsdTicks: z.number().optional(),
|
|
439
|
+
}),
|
|
440
|
+
// Absent when xAI reported no cost and the model has no catalog price.
|
|
441
|
+
costUsd: z.number().optional(),
|
|
442
|
+
costSource: MediaCostSource.optional(),
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
export type GenerateImagesOutput = z.infer<typeof GenerateImagesOutput>;
|
|
446
|
+
|
|
447
|
+
export const VideoStartInput = z
|
|
448
|
+
.object({
|
|
449
|
+
model: GrokModelId,
|
|
450
|
+
prompt: z.string().min(1),
|
|
451
|
+
duration: z.number().int().min(1).max(15).optional(),
|
|
452
|
+
aspectRatio: z.string().min(1).max(16).optional(),
|
|
453
|
+
resolution: z.enum(["480p", "720p", "1080p"]).optional(),
|
|
454
|
+
image: MediaImageRef.optional(),
|
|
455
|
+
lastFrame: MediaImageRef.optional(),
|
|
456
|
+
referenceImages: z.array(MediaImageRef).min(1).max(MEDIA_MAX_REFERENCE_IMAGES).optional(),
|
|
457
|
+
// edit-video and extend-video need a source video, which qgrid does not accept.
|
|
458
|
+
mode: z.enum(["reference-to-video"]).optional(),
|
|
459
|
+
...MediaCallOptions,
|
|
460
|
+
})
|
|
461
|
+
.refine((input) => input.mode !== "reference-to-video" || input.referenceImages !== undefined, {
|
|
462
|
+
message: "reference-to-video needs at least one referenceImages entry",
|
|
463
|
+
path: ["referenceImages"],
|
|
464
|
+
})
|
|
465
|
+
// Every inline image shares the one request body.
|
|
466
|
+
.refine(
|
|
467
|
+
(input) =>
|
|
468
|
+
inlineImageBytes([input.image, input.lastFrame, ...(input.referenceImages ?? [])]) <=
|
|
469
|
+
MEDIA_MAX_INLINE_BYTES,
|
|
470
|
+
{ message: INLINE_IMAGES_TOTAL_MESSAGE, path: ["referenceImages"] },
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
export type VideoStartInput = z.infer<typeof VideoStartInput>;
|
|
474
|
+
|
|
475
|
+
export const VideoStartOutput = z.object({
|
|
476
|
+
// Unguessable server-side handle; polling must present the same projectName as the start.
|
|
477
|
+
jobHandle: z.string(),
|
|
478
|
+
model: z.string(),
|
|
479
|
+
requestLogId: z.number().optional(),
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
export type VideoStartOutput = z.infer<typeof VideoStartOutput>;
|
|
483
|
+
|
|
484
|
+
export const VideoStatusInput = z.object({
|
|
485
|
+
jobHandle: z.string().regex(/^[A-Za-z0-9_-]{22}$/),
|
|
486
|
+
projectName: z.string().optional(),
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
export type VideoStatusInput = z.infer<typeof VideoStatusInput>;
|
|
490
|
+
|
|
491
|
+
export const VideoStatusOutput = z.object({
|
|
492
|
+
status: z.enum(["pending", "done", "failed"]),
|
|
493
|
+
// The upstream api.x.ai URL, returned unchanged; qgrid never fetches or stores the video.
|
|
494
|
+
url: z.string().optional(),
|
|
495
|
+
mimeType: z.literal("video/mp4"),
|
|
496
|
+
durationSec: z.number().optional(),
|
|
497
|
+
costInUsdTicks: z.number().optional(),
|
|
498
|
+
costUsd: z.number().optional(),
|
|
499
|
+
error: z.string().optional(),
|
|
500
|
+
requestLogId: z.number().optional(),
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
export type VideoStatusOutput = z.infer<typeof VideoStatusOutput>;
|
|
504
|
+
|
|
505
|
+
export const TranscribeInput = z.object({
|
|
506
|
+
model: GrokModelId.optional(),
|
|
507
|
+
// Base64 audio bytes (no data: prefix), at most MEDIA_MAX_INLINE_BYTES decoded.
|
|
508
|
+
audio: z
|
|
509
|
+
.string()
|
|
510
|
+
.min(1)
|
|
511
|
+
.refine((value) => value.length % 4 === 0 && BASE64.test(value), "audio must be base64")
|
|
512
|
+
.refine(
|
|
513
|
+
(value) => base64DecodedBytes(value) <= MEDIA_MAX_INLINE_BYTES,
|
|
514
|
+
`audio exceeds ${MEDIA_MAX_INLINE_LABEL}`,
|
|
515
|
+
),
|
|
516
|
+
mediaType: z.string().regex(/^audio\/[A-Za-z0-9.+-]+$/, "mediaType must be audio/*"),
|
|
517
|
+
language: z.string().min(1).max(16).optional(),
|
|
518
|
+
...MediaCallOptions,
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
export type TranscribeInput = z.infer<typeof TranscribeInput>;
|
|
522
|
+
|
|
523
|
+
export const TranscribeOutput = z.object({
|
|
524
|
+
text: z.string(),
|
|
525
|
+
language: z.string().optional(),
|
|
526
|
+
durationSec: z.number().optional(),
|
|
527
|
+
model: z.string(),
|
|
528
|
+
tokenName: z.string(),
|
|
529
|
+
requestLogId: z.number().optional(),
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
export type TranscribeOutput = z.infer<typeof TranscribeOutput>;
|
|
533
|
+
|
|
534
|
+
export const SpeakInput = z.object({
|
|
535
|
+
model: GrokModelId.optional(),
|
|
536
|
+
text: z.string().min(1).max(15_000),
|
|
537
|
+
voice: z.string().min(1).max(64).optional(),
|
|
538
|
+
language: z.string().min(1).max(16).optional(),
|
|
539
|
+
format: z.enum(["mp3", "wav", "pcm", "mulaw", "alaw"]).optional(),
|
|
540
|
+
...MediaCallOptions,
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
export type SpeakInput = z.infer<typeof SpeakInput>;
|
|
544
|
+
|
|
545
|
+
export const SpeakOutput = z.object({
|
|
546
|
+
// Base64 audio bytes.
|
|
547
|
+
audio: z.string(),
|
|
548
|
+
mimeType: z.string(),
|
|
549
|
+
tokenName: z.string(),
|
|
550
|
+
requestLogId: z.number().optional(),
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
export type SpeakOutput = z.infer<typeof SpeakOutput>;
|
|
554
|
+
|
|
264
555
|
// ─── Run Lifecycle ───
|
|
265
556
|
|
|
266
557
|
export const CreateRunInput = z.object({
|
|
@@ -273,6 +564,7 @@ export const CreateRunInput = z.object({
|
|
|
273
564
|
isStructured: z.boolean().optional(),
|
|
274
565
|
jsonSchema: z.string().nullable().optional(),
|
|
275
566
|
});
|
|
567
|
+
|
|
276
568
|
export type CreateRunInput = z.infer<typeof CreateRunInput>;
|
|
277
569
|
|
|
278
570
|
export const AppendStepInput = z.object({
|
|
@@ -303,6 +595,7 @@ export const AppendStepInput = z.object({
|
|
|
303
595
|
toolDurationMs: z.number().optional(),
|
|
304
596
|
error: z.string().optional(),
|
|
305
597
|
});
|
|
598
|
+
|
|
306
599
|
export type AppendStepInput = z.infer<typeof AppendStepInput>;
|
|
307
600
|
|
|
308
601
|
export const FinishRunInput = z.object({
|
|
@@ -326,6 +619,7 @@ export const FinishRunInput = z.object({
|
|
|
326
619
|
errorMessage: z.string().optional(),
|
|
327
620
|
responseJsonOk: z.boolean().optional(),
|
|
328
621
|
});
|
|
622
|
+
|
|
329
623
|
export type FinishRunInput = z.infer<typeof FinishRunInput>;
|
|
330
624
|
|
|
331
625
|
// ─── Token Management ───
|
|
@@ -336,6 +630,7 @@ export const TokenStats = z.object({
|
|
|
336
630
|
provider: z.string(),
|
|
337
631
|
requests: z.number(),
|
|
338
632
|
});
|
|
633
|
+
|
|
339
634
|
export type TokenStats = z.infer<typeof TokenStats>;
|
|
340
635
|
|
|
341
636
|
// ─── OAuth ───
|
|
@@ -346,8 +641,31 @@ export const OAuthStartResult = z.object({
|
|
|
346
641
|
// OpenAI 원격 경로는 등록된 loopback callback URL 전체를 붙여넣는 code 모드를 쓴다.
|
|
347
642
|
mode: z.enum(["redirect", "code"]),
|
|
348
643
|
});
|
|
644
|
+
|
|
349
645
|
export type OAuthStartResult = z.infer<typeof OAuthStartResult>;
|
|
350
646
|
|
|
647
|
+
// Grok device-code login (RFC 8628). The web shows userCode/verificationUri and polls
|
|
648
|
+
// oauthPollGrokDevice every `interval` seconds until `added` or an error.
|
|
649
|
+
export const GrokDeviceCodeStart = z.object({
|
|
650
|
+
deviceCode: z.string(),
|
|
651
|
+
userCode: z.string(),
|
|
652
|
+
verificationUri: z.string(),
|
|
653
|
+
verificationUriComplete: z.string().optional(),
|
|
654
|
+
expiresIn: z.number(),
|
|
655
|
+
interval: z.number(),
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
export type GrokDeviceCodeStart = z.infer<typeof GrokDeviceCodeStart>;
|
|
659
|
+
|
|
660
|
+
export const GrokDevicePollResult = z.object({
|
|
661
|
+
status: z.enum(["pending", "slow_down", "added"]),
|
|
662
|
+
name: z.string().optional(),
|
|
663
|
+
// Seconds to wait before the next poll; grows on slow_down.
|
|
664
|
+
intervalSec: z.number().optional(),
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
export type GrokDevicePollResult = z.infer<typeof GrokDevicePollResult>;
|
|
668
|
+
|
|
351
669
|
const RateWindow = z
|
|
352
670
|
.object({
|
|
353
671
|
utilization: z.number().nullable(),
|
|
@@ -361,7 +679,17 @@ export const UsageResponse = z.object({
|
|
|
361
679
|
provider: z.string().optional(),
|
|
362
680
|
fiveHour: RateWindow.optional(),
|
|
363
681
|
sevenDay: RateWindow.optional(),
|
|
682
|
+
// Grok: billing period label (USAGE_PERIOD_TYPE_WEEKLY|MONTHLY); the window itself is in sevenDay.
|
|
683
|
+
periodType: z.string().nullable().optional(),
|
|
684
|
+
tier: z.string().nullable().optional(),
|
|
685
|
+
// Grok D6: on-demand billing enabled at xAI excludes the token from routing.
|
|
686
|
+
onDemandExcluded: z.boolean().optional(),
|
|
687
|
+
// Grok: Zero Data Retention at xAI excludes the token from video only (plan §11).
|
|
688
|
+
zdrVideoExcluded: z.boolean().optional(),
|
|
689
|
+
// Grok: token-window keepalive does not apply; the UI says so.
|
|
690
|
+
keepaliveApplicable: z.boolean().optional(),
|
|
364
691
|
});
|
|
692
|
+
|
|
365
693
|
export type UsageResponse = z.infer<typeof UsageResponse>;
|
|
366
694
|
|
|
367
695
|
// ─── Health ───
|
|
@@ -372,9 +700,11 @@ export const SubscriberStatus = z.object({
|
|
|
372
700
|
lastReconcileAt: z.date().nullable(),
|
|
373
701
|
attempt: z.number(),
|
|
374
702
|
});
|
|
703
|
+
|
|
375
704
|
export type SubscriberStatus = z.infer<typeof SubscriberStatus>;
|
|
376
705
|
|
|
377
706
|
export const ProviderStartupState = z.enum(["starting", "ready", "failed"]);
|
|
707
|
+
|
|
378
708
|
export type ProviderStartupState = z.infer<typeof ProviderStartupState>;
|
|
379
709
|
|
|
380
710
|
export const HealthResponse = z.object({
|
|
@@ -387,8 +717,10 @@ export const HealthResponse = z.object({
|
|
|
387
717
|
providers: z.object({
|
|
388
718
|
openai: ProviderStartupState,
|
|
389
719
|
anthropic: ProviderStartupState,
|
|
720
|
+
grok: ProviderStartupState.optional(),
|
|
390
721
|
}),
|
|
391
722
|
});
|
|
723
|
+
|
|
392
724
|
export type HealthResponse = z.infer<typeof HealthResponse>;
|
|
393
725
|
|
|
394
726
|
// ─── Errors ───
|
|
@@ -396,12 +728,15 @@ export type HealthResponse = z.infer<typeof HealthResponse>;
|
|
|
396
728
|
export class QuotaError extends Error {
|
|
397
729
|
readonly code = "QUOTA_EXHAUSTED" as const;
|
|
398
730
|
}
|
|
731
|
+
|
|
399
732
|
export class QuotaThresholdExceededError extends Error {
|
|
400
733
|
readonly code = "QUOTA_THRESHOLD_EXCEEDED" as const;
|
|
401
734
|
}
|
|
735
|
+
|
|
402
736
|
export class TimeoutError extends Error {
|
|
403
737
|
readonly code = "TIMEOUT" as const;
|
|
404
738
|
}
|
|
739
|
+
|
|
405
740
|
export class ProcessError extends Error {
|
|
406
741
|
readonly code = "PROCESS_ERROR" as const;
|
|
407
742
|
}
|