@cartanova/qgrid-cli 2.10.10 → 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 +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-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-NP-ValHd.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-CgBdabgd.js → lazyRouteComponent-D8iTIHyn.js} +129 -2
- package/bundle/web-dist/server/assets/logs-B3OTd9hy.js +825 -0
- package/bundle/web-dist/server/assets/{monit-ZPt66W5M.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-Ds75e4Jl.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-DjGldb-h.js → request-model-I6OdODSH.js} +15 -6
- package/bundle/web-dist/server/assets/{routes-Ct-k7nBA.js → routes-B95YlUv2.js} +760 -213
- package/bundle/web-dist/server/assets/{services.generated-BA4AcAf5.js → services.generated-DQATJ6qf.js} +12820 -12194
- package/bundle/web-dist/server/assets/settings-C3gbGk0m.js +830 -0
- package/bundle/web-dist/server/assets/{show-LSFIzvO2.js → show-Bxaj3rhH.js} +1350 -418
- 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-pkArIzCP.js → use-update-token-mutation-BEbgOzaa.js} +1 -1
- package/bundle/web-dist/server/entry-server.generated.js +4295 -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 +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/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-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/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-BMyR98rU.js +0 -509
- package/bundle/web-dist/server/assets/plus-BZ9I0VgC.js +0 -19
- package/bundle/web-dist/server/assets/refresh-cw-CztCFis-.js +0 -23
- package/bundle/web-dist/server/assets/settings-CBUZ47Xx.js +0 -461
- package/bundle/web-dist/server/assets/tokens-DxrBW512.js +0 -448
- 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/{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
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
+
import { type ClientRequest } from "node:http";
|
|
2
3
|
|
|
3
4
|
import WsClient, { type ClientOptions, type RawData } from "ws";
|
|
5
|
+
import { z } from "zod";
|
|
4
6
|
|
|
5
7
|
import {
|
|
6
8
|
buildCodexIdentityHeaders,
|
|
7
9
|
buildOpenAIResponsesRequest,
|
|
8
10
|
CHATGPT_CODEX_RESPONSES_URL,
|
|
11
|
+
type JsonValue,
|
|
9
12
|
normalizeOpenAIEvent,
|
|
10
13
|
OpenAIProtocolError,
|
|
11
14
|
type OpenAINormalizedEvent,
|
|
@@ -49,7 +52,7 @@ export interface OpenAIWebSocketLike {
|
|
|
49
52
|
on(event: "error", listener: (error: Error) => void): this;
|
|
50
53
|
on(
|
|
51
54
|
event: "unexpected-response",
|
|
52
|
-
listener: (request:
|
|
55
|
+
listener: (request: ClientRequest, response: { statusCode?: number }) => void,
|
|
53
56
|
): this;
|
|
54
57
|
off(event: string, listener: (...args: never[]) => void): this;
|
|
55
58
|
send(data: string, callback?: (error?: Error) => void): void;
|
|
@@ -74,18 +77,23 @@ const MAX_BUFFERED_SOCKET_RECORDS = 1600;
|
|
|
74
77
|
|
|
75
78
|
function websocketUrl(url: string): string {
|
|
76
79
|
let parsed: URL;
|
|
80
|
+
|
|
77
81
|
try {
|
|
78
82
|
parsed = new URL(url);
|
|
79
83
|
} catch (error) {
|
|
80
84
|
throw new OpenAIProtocolError(`Invalid OpenAI Responses URL: ${String(error)}`);
|
|
81
85
|
}
|
|
86
|
+
|
|
82
87
|
parsed.protocol = parsed.protocol === "https:" ? "wss:" : "ws:";
|
|
88
|
+
|
|
83
89
|
return parsed.toString();
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
function rawDataText(data: RawData): string {
|
|
87
93
|
if (Array.isArray(data)) return Buffer.concat(data).toString();
|
|
94
|
+
|
|
88
95
|
if (data instanceof ArrayBuffer) return Buffer.from(new Uint8Array(data)).toString();
|
|
96
|
+
|
|
89
97
|
return Buffer.from(data).toString();
|
|
90
98
|
}
|
|
91
99
|
|
|
@@ -93,15 +101,18 @@ function socketEvents(socket: OpenAIWebSocketLike, signal?: AbortSignal) {
|
|
|
93
101
|
const records: SocketRecord[] = [];
|
|
94
102
|
const waiters: Array<(record: SocketRecord) => void> = [];
|
|
95
103
|
let active = true;
|
|
104
|
+
|
|
96
105
|
const push = (record: SocketRecord) => {
|
|
97
106
|
if (!active) return;
|
|
98
107
|
const waiter = waiters.shift();
|
|
108
|
+
|
|
99
109
|
if (waiter) waiter(record);
|
|
100
110
|
else if (records.length < MAX_BUFFERED_SOCKET_RECORDS) records.push(record);
|
|
101
111
|
else {
|
|
102
112
|
active = false;
|
|
103
113
|
records.length = 0;
|
|
104
114
|
socket.terminate();
|
|
115
|
+
|
|
105
116
|
const overflow = {
|
|
106
117
|
kind: "error" as const,
|
|
107
118
|
error: new OpenAIProtocolError(
|
|
@@ -109,28 +120,38 @@ function socketEvents(socket: OpenAIWebSocketLike, signal?: AbortSignal) {
|
|
|
109
120
|
"websocket_backpressure",
|
|
110
121
|
),
|
|
111
122
|
};
|
|
123
|
+
|
|
112
124
|
const overflowWaiter = waiters.shift();
|
|
125
|
+
|
|
113
126
|
if (overflowWaiter) overflowWaiter(overflow);
|
|
114
127
|
else records.push(overflow);
|
|
115
128
|
}
|
|
116
129
|
};
|
|
130
|
+
|
|
117
131
|
const onOpen = () => push({ kind: "open" });
|
|
118
132
|
const onMessage = (data: RawData, isBinary: boolean) => push({ kind: "message", data, isBinary });
|
|
133
|
+
|
|
119
134
|
const onClose = (code: number, reason: Buffer) =>
|
|
120
135
|
push({ kind: "close", code, reason: reason.toString() });
|
|
136
|
+
|
|
121
137
|
const onError = (error: Error) => push({ kind: "error", error });
|
|
122
|
-
|
|
138
|
+
|
|
139
|
+
const onUnexpectedResponse = (_request: ClientRequest, response: { statusCode?: number }) =>
|
|
123
140
|
push({ kind: "rejected", status: response.statusCode });
|
|
141
|
+
|
|
124
142
|
socket.on("open", onOpen);
|
|
125
143
|
socket.on("message", onMessage);
|
|
126
144
|
socket.on("close", onClose);
|
|
127
145
|
socket.on("error", onError);
|
|
128
146
|
socket.on("unexpected-response", onUnexpectedResponse);
|
|
147
|
+
|
|
129
148
|
const onAbort = () => {
|
|
130
149
|
socket.terminate();
|
|
131
150
|
push({ kind: "error", error: abortError(signal) });
|
|
132
151
|
};
|
|
152
|
+
|
|
133
153
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
154
|
+
|
|
134
155
|
return {
|
|
135
156
|
next: () =>
|
|
136
157
|
records.length
|
|
@@ -146,10 +167,12 @@ function socketEvents(socket: OpenAIWebSocketLike, signal?: AbortSignal) {
|
|
|
146
167
|
// 다음 tick에 error를 emit하므로, 떼어 두면 Unhandled 'error'로 프로세스가 죽는다.
|
|
147
168
|
socket.off("unexpected-response", onUnexpectedResponse);
|
|
148
169
|
records.length = 0;
|
|
170
|
+
|
|
149
171
|
const closed = {
|
|
150
172
|
kind: "error" as const,
|
|
151
173
|
error: new OpenAIProtocolError("OpenAI WebSocket event stream was closed"),
|
|
152
174
|
};
|
|
175
|
+
|
|
153
176
|
waiters.splice(0).forEach((waiter) => waiter(closed));
|
|
154
177
|
},
|
|
155
178
|
detachAbort: () => signal?.removeEventListener("abort", onAbort),
|
|
@@ -168,12 +191,15 @@ async function nextPooledRecord(
|
|
|
168
191
|
signal?: AbortSignal,
|
|
169
192
|
): Promise<SocketRecord> {
|
|
170
193
|
if (!signal) return events.next();
|
|
194
|
+
|
|
171
195
|
if (signal.aborted) throw abortError(signal);
|
|
196
|
+
|
|
172
197
|
return new Promise<SocketRecord>((resolve, reject) => {
|
|
173
198
|
const onAbort = () => {
|
|
174
199
|
socket.terminate();
|
|
175
200
|
reject(abortError(signal));
|
|
176
201
|
};
|
|
202
|
+
|
|
177
203
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
178
204
|
void events
|
|
179
205
|
.next()
|
|
@@ -188,6 +214,7 @@ function cacheAffinityUuid(key: string): string {
|
|
|
188
214
|
const hex = crypto.createHash("sha256").update(key).digest("hex").slice(0, 32).split("");
|
|
189
215
|
hex[12] = "4";
|
|
190
216
|
hex[16] = ((Number.parseInt(hex[16]!, 16) & 0x3) | 0x8).toString(16);
|
|
217
|
+
|
|
191
218
|
return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
|
|
192
219
|
}
|
|
193
220
|
|
|
@@ -230,40 +257,52 @@ export class OpenAIWebSocketTransport implements OpenAIResponsesTransport {
|
|
|
230
257
|
const idleKey = [...this.affinityConnections.keys()].find(
|
|
231
258
|
(key) => !this.busyAffinities.has(key),
|
|
232
259
|
);
|
|
260
|
+
|
|
233
261
|
if (idleKey === undefined) return false;
|
|
234
262
|
const idle = this.affinityConnections.get(idleKey)!;
|
|
235
263
|
idle.events.cleanup();
|
|
236
264
|
idle.socket.close(1000, "affinity cache evicted");
|
|
237
265
|
this.affinityConnections.delete(idleKey);
|
|
238
266
|
}
|
|
267
|
+
|
|
239
268
|
this.affinityConnections.set(threadId, connection);
|
|
269
|
+
|
|
240
270
|
// 유휴 상태에서 backend 가 끊은 소켓을 다음 요청이 집어들지 않도록 캐시에서 제거한다.
|
|
241
271
|
const drop = () => {
|
|
242
272
|
connection.closed = true;
|
|
273
|
+
|
|
243
274
|
if (this.busyAffinities.has(threadId)) return;
|
|
275
|
+
|
|
244
276
|
if (this.affinityConnections.get(threadId) !== connection) return;
|
|
245
277
|
this.affinityConnections.delete(threadId);
|
|
246
278
|
connection.events.cleanup();
|
|
247
279
|
};
|
|
280
|
+
|
|
248
281
|
connection.socket.on("close", drop);
|
|
249
282
|
connection.socket.on("error", drop);
|
|
283
|
+
|
|
250
284
|
return true;
|
|
251
285
|
}
|
|
252
286
|
|
|
253
287
|
async *stream(request: OpenAITransportRequest): AsyncGenerator<OpenAINormalizedEvent> {
|
|
254
288
|
let refreshed = false;
|
|
289
|
+
|
|
255
290
|
while (true) {
|
|
256
291
|
if (request.signal?.aborted) throw abortError(request.signal);
|
|
257
292
|
const hasAffinity = request.body.prompt_cache_key !== undefined;
|
|
258
293
|
const retainConnection = hasAffinity && !this.busyAffinities.has(request.threadId);
|
|
294
|
+
|
|
259
295
|
if (retainConnection) this.busyAffinities.add(request.threadId);
|
|
260
296
|
const entry = retainConnection ? this.affinityConnections.get(request.threadId) : undefined;
|
|
297
|
+
|
|
261
298
|
if (entry?.closed) {
|
|
262
299
|
this.affinityConnections.delete(request.threadId);
|
|
263
300
|
entry.events.cleanup();
|
|
264
301
|
}
|
|
302
|
+
|
|
265
303
|
const cached = entry?.closed ? undefined : entry;
|
|
266
304
|
let retained = retainConnection;
|
|
305
|
+
|
|
267
306
|
const socket =
|
|
268
307
|
cached?.socket ??
|
|
269
308
|
this.webSocketFactory(websocketUrl(CHATGPT_CODEX_RESPONSES_URL), {
|
|
@@ -276,11 +315,14 @@ export class OpenAIWebSocketTransport implements OpenAIResponsesTransport {
|
|
|
276
315
|
"OpenAI-Beta": "responses_websockets=2026-02-06",
|
|
277
316
|
},
|
|
278
317
|
});
|
|
318
|
+
|
|
279
319
|
const events = cached?.events ?? socketEvents(socket, request.signal);
|
|
280
320
|
let completed = false;
|
|
321
|
+
|
|
281
322
|
try {
|
|
282
323
|
if (!cached) {
|
|
283
324
|
const handshake = await events.next();
|
|
325
|
+
|
|
284
326
|
if (
|
|
285
327
|
handshake.kind === "rejected" &&
|
|
286
328
|
handshake.status === 401 &&
|
|
@@ -292,6 +334,7 @@ export class OpenAIWebSocketTransport implements OpenAIResponsesTransport {
|
|
|
292
334
|
refreshed = true;
|
|
293
335
|
continue;
|
|
294
336
|
}
|
|
337
|
+
|
|
295
338
|
if (handshake.kind === "rejected") {
|
|
296
339
|
throw new OpenAIProtocolError(
|
|
297
340
|
`OpenAI WebSocket handshake rejected${handshake.status ? ` with HTTP ${handshake.status}` : ""}`,
|
|
@@ -299,10 +342,13 @@ export class OpenAIWebSocketTransport implements OpenAIResponsesTransport {
|
|
|
299
342
|
handshake.status,
|
|
300
343
|
);
|
|
301
344
|
}
|
|
345
|
+
|
|
302
346
|
if (handshake.kind === "error") throw handshake.error;
|
|
347
|
+
|
|
303
348
|
if (handshake.kind !== "open") {
|
|
304
349
|
throw new OpenAIProtocolError("OpenAI WebSocket closed before the handshake completed");
|
|
305
350
|
}
|
|
351
|
+
|
|
306
352
|
if (retainConnection) {
|
|
307
353
|
retained = this.rememberAffinityConnection(request.threadId, { socket, events });
|
|
308
354
|
}
|
|
@@ -318,26 +364,37 @@ export class OpenAIWebSocketTransport implements OpenAIResponsesTransport {
|
|
|
318
364
|
const record = cached
|
|
319
365
|
? await nextPooledRecord(events, socket, request.signal)
|
|
320
366
|
: await events.next();
|
|
367
|
+
|
|
321
368
|
if (record.kind === "message") {
|
|
322
369
|
if (record.isBinary) {
|
|
323
370
|
throw new OpenAIProtocolError("OpenAI WebSocket sent an unexpected binary message");
|
|
324
371
|
}
|
|
325
|
-
|
|
372
|
+
|
|
373
|
+
let raw: JsonValue;
|
|
374
|
+
|
|
326
375
|
try {
|
|
376
|
+
// JSON.parse without a reviver yields only JSON values.
|
|
327
377
|
raw = JSON.parse(rawDataText(record.data));
|
|
328
378
|
} catch {
|
|
329
379
|
throw new OpenAIProtocolError("OpenAI WebSocket sent invalid JSON");
|
|
330
380
|
}
|
|
381
|
+
|
|
331
382
|
const event = normalizeOpenAIEvent(raw);
|
|
383
|
+
|
|
332
384
|
if (!event) continue;
|
|
385
|
+
|
|
333
386
|
if (event.type === "completed") {
|
|
334
387
|
completed = true;
|
|
388
|
+
|
|
335
389
|
if (retained) events.detachAbort();
|
|
336
390
|
else socket.close(1000, "response completed");
|
|
337
391
|
yield event;
|
|
392
|
+
|
|
338
393
|
return;
|
|
339
394
|
}
|
|
395
|
+
|
|
340
396
|
yield event;
|
|
397
|
+
|
|
341
398
|
if (event.type === "error") throw event.error;
|
|
342
399
|
} else if (record.kind === "error") {
|
|
343
400
|
throw record.error;
|
|
@@ -353,33 +410,58 @@ export class OpenAIWebSocketTransport implements OpenAIResponsesTransport {
|
|
|
353
410
|
if (!completed || !retained) {
|
|
354
411
|
if (retained) this.affinityConnections.delete(request.threadId);
|
|
355
412
|
events.cleanup();
|
|
413
|
+
|
|
356
414
|
if (!completed) socket.terminate();
|
|
357
415
|
}
|
|
416
|
+
|
|
358
417
|
if (retainConnection) this.busyAffinities.delete(request.threadId);
|
|
359
418
|
}
|
|
360
419
|
}
|
|
361
420
|
}
|
|
362
421
|
}
|
|
363
422
|
|
|
423
|
+
// OpenAI error bodies carry `error` as a string or as { message, code }; mistyped fields are ignored.
|
|
424
|
+
const openAIErrorBodySchema = z.looseObject({
|
|
425
|
+
error: z.unknown().optional(),
|
|
426
|
+
message: z.string().optional().catch(undefined),
|
|
427
|
+
code: z.string().optional().catch(undefined),
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const openAIErrorDetailSchema = z.looseObject({
|
|
431
|
+
message: z.string().optional().catch(undefined),
|
|
432
|
+
code: z.string().optional().catch(undefined),
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
function requestsTransparentImage(
|
|
436
|
+
imageGeneration: OpenAIResponsesOptions["imageGeneration"],
|
|
437
|
+
): boolean {
|
|
438
|
+
return (
|
|
439
|
+
imageGeneration !== undefined &&
|
|
440
|
+
imageGeneration !== true &&
|
|
441
|
+
imageGeneration !== false &&
|
|
442
|
+
imageGeneration.background === "transparent"
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
364
446
|
async function responseError(response: Response): Promise<OpenAIProtocolError> {
|
|
365
447
|
const text = await response.text().catch(() => "");
|
|
366
448
|
let message = text || response.statusText || `HTTP ${response.status}`;
|
|
367
449
|
let code: string | undefined;
|
|
450
|
+
|
|
368
451
|
try {
|
|
369
|
-
const parsed = JSON.parse(text)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
(typeof error === "string" ? error : message);
|
|
379
|
-
code = (typeof error === "object" ? error.code : undefined) ?? parsed.code;
|
|
452
|
+
const parsed = openAIErrorBodySchema.safeParse(JSON.parse(text));
|
|
453
|
+
|
|
454
|
+
if (parsed.success) {
|
|
455
|
+
const error = parsed.data.error;
|
|
456
|
+
const errorDetail = openAIErrorDetailSchema.safeParse(error).data;
|
|
457
|
+
message =
|
|
458
|
+
errorDetail?.message ?? parsed.data.message ?? z.string().safeParse(error).data ?? message;
|
|
459
|
+
code = errorDetail?.code ?? parsed.data.code;
|
|
460
|
+
}
|
|
380
461
|
} catch {
|
|
381
462
|
code = undefined;
|
|
382
463
|
}
|
|
464
|
+
|
|
383
465
|
return new OpenAIProtocolError(message, code, response.status);
|
|
384
466
|
}
|
|
385
467
|
|
|
@@ -419,12 +501,15 @@ export class OpenAIHttpsTransport implements OpenAIResponsesTransport {
|
|
|
419
501
|
refreshed = true;
|
|
420
502
|
continue;
|
|
421
503
|
}
|
|
504
|
+
|
|
422
505
|
if (!response.ok) throw await responseError(response);
|
|
506
|
+
|
|
423
507
|
if (!response.body) throw new OpenAIProtocolError("OpenAI response had no body");
|
|
424
508
|
|
|
425
509
|
for await (const event of normalizeOpenAISSE(response.body)) {
|
|
426
510
|
yield event;
|
|
427
511
|
}
|
|
512
|
+
|
|
428
513
|
return;
|
|
429
514
|
}
|
|
430
515
|
}
|
|
@@ -450,17 +535,16 @@ export class OpenAIDirectClient {
|
|
|
450
535
|
}
|
|
451
536
|
|
|
452
537
|
responses(options: OpenAIResponsesOptions, signal?: AbortSignal): OpenAIEventStream {
|
|
453
|
-
if (
|
|
454
|
-
options.model === "gpt-image-2" ||
|
|
455
|
-
(typeof options.imageGeneration === "object" &&
|
|
456
|
-
options.imageGeneration.background === "transparent")
|
|
457
|
-
) {
|
|
538
|
+
if (options.model === "gpt-image-2" || requestsTransparentImage(options.imageGeneration)) {
|
|
458
539
|
return this.standaloneImages(options, signal);
|
|
459
540
|
}
|
|
541
|
+
|
|
460
542
|
const clientRequestId = crypto.randomUUID();
|
|
543
|
+
|
|
461
544
|
const affinityId = options.promptCacheKey
|
|
462
545
|
? cacheAffinityUuid(options.promptCacheKey)
|
|
463
546
|
: clientRequestId;
|
|
547
|
+
|
|
464
548
|
return this.transport.stream({
|
|
465
549
|
body: buildOpenAIResponsesRequest(
|
|
466
550
|
options.promptCacheKey ? { ...options, promptCacheKey: affinityId } : options,
|
|
@@ -479,8 +563,10 @@ export class OpenAIDirectClient {
|
|
|
479
563
|
): OpenAIEventStream {
|
|
480
564
|
const request = buildStandaloneImageRequest(options);
|
|
481
565
|
const requestId = crypto.randomUUID();
|
|
566
|
+
|
|
482
567
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
483
568
|
signal?.throwIfAborted();
|
|
569
|
+
|
|
484
570
|
const response = await (this.options.fetch ?? fetch)(request.url, {
|
|
485
571
|
method: "POST",
|
|
486
572
|
headers: {
|
|
@@ -494,17 +580,20 @@ export class OpenAIDirectClient {
|
|
|
494
580
|
body: JSON.stringify(request.body),
|
|
495
581
|
signal,
|
|
496
582
|
});
|
|
583
|
+
|
|
497
584
|
if (response.status === 401 && attempt === 0 && this.options.refreshCredentials) {
|
|
498
585
|
await response.body?.cancel();
|
|
499
586
|
this.imageCredentials = await this.options.refreshCredentials();
|
|
500
587
|
continue;
|
|
501
588
|
}
|
|
589
|
+
|
|
502
590
|
if (!response.ok) throw await responseError(response);
|
|
591
|
+
|
|
503
592
|
const images = await readStandaloneImageResponse(
|
|
504
593
|
response,
|
|
505
|
-
|
|
506
|
-
options.imageGeneration.background === "transparent",
|
|
594
|
+
requestsTransparentImage(options.imageGeneration),
|
|
507
595
|
);
|
|
596
|
+
|
|
508
597
|
signal?.throwIfAborted();
|
|
509
598
|
yield* images;
|
|
510
599
|
const firstImage = images[0];
|
|
@@ -513,6 +602,7 @@ export class OpenAIDirectClient {
|
|
|
513
602
|
responseId: requestId,
|
|
514
603
|
model: firstImage?.type === "image" ? firstImage.generation?.model : "gpt-image-2",
|
|
515
604
|
};
|
|
605
|
+
|
|
516
606
|
return;
|
|
517
607
|
}
|
|
518
608
|
}
|