@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
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
* - 렌더된 계약은 parseEnvelope 의 zod 계약({"result": ...} 한 겹, 상호배타 변형)과
|
|
16
16
|
* 정확히 일치해야 한다 — 교차 테스트(schema-prompt.test.ts)가 드리프트를 막는다.
|
|
17
17
|
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
isJsonObject,
|
|
22
|
+
type JsonObject,
|
|
23
|
+
type JsonValue,
|
|
24
|
+
jsonValueSchema,
|
|
25
|
+
} from "../../utils/providers/common/provider-types";
|
|
18
26
|
import { type QgridTool, type QueryInput } from "./qgrid.types";
|
|
19
27
|
|
|
20
28
|
/**
|
|
@@ -27,7 +35,9 @@ export function composeSystemWithSchemaContract(
|
|
|
27
35
|
input: Pick<QueryInput, "tools" | "jsonSchema">,
|
|
28
36
|
): string | undefined {
|
|
29
37
|
const contract = renderSchemaContractPrompt(input);
|
|
38
|
+
|
|
30
39
|
if (contract === undefined) return system;
|
|
40
|
+
|
|
31
41
|
return system ? `${system}\n\n${contract}` : contract;
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -38,9 +48,11 @@ export function renderSchemaContractPrompt(
|
|
|
38
48
|
if (input.tools?.length) {
|
|
39
49
|
return renderToolEnvelopePrompt(input.tools, input.jsonSchema);
|
|
40
50
|
}
|
|
51
|
+
|
|
41
52
|
if (input.jsonSchema !== undefined) {
|
|
42
53
|
return renderOutputSchemaPrompt(input.jsonSchema);
|
|
43
54
|
}
|
|
55
|
+
|
|
44
56
|
return undefined;
|
|
45
57
|
}
|
|
46
58
|
|
|
@@ -68,33 +80,47 @@ export function renderOutputSchemaPrompt(jsonSchema: string): string {
|
|
|
68
80
|
* 있으면 **fail-closed** — 위반 가능성이 있는 예시를 싣는 대신 예시 자체를 생략하고
|
|
69
81
|
* 렌더러가 프로즈 서술로 대체한다 (`toolCallExample: undefined`).
|
|
70
82
|
*/
|
|
71
|
-
export
|
|
83
|
+
export interface EnvelopeExamples {
|
|
72
84
|
toolCallExample?: string;
|
|
73
85
|
textAnswerExample: string;
|
|
74
|
-
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function buildEnvelopeExamples(tools: QgridTool[]): EnvelopeExamples {
|
|
75
89
|
const firstTool = tools[0];
|
|
76
|
-
const args =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
? {
|
|
80
|
-
toolCallExample: JSON.stringify({
|
|
81
|
-
result: {
|
|
82
|
-
action: "tool_call",
|
|
83
|
-
answer: null,
|
|
84
|
-
toolCalls: [
|
|
85
|
-
{ toolName: firstTool?.name ?? "toolName", args: JSON.stringify(args.value) },
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
}),
|
|
89
|
-
}
|
|
90
|
-
: {}),
|
|
90
|
+
const args = exampleArgsForTool(firstTool);
|
|
91
|
+
|
|
92
|
+
const examples: EnvelopeExamples = {
|
|
91
93
|
textAnswerExample: JSON.stringify({
|
|
92
94
|
result: { action: "answer", answer: "your final answer", toolCalls: null },
|
|
93
95
|
}),
|
|
94
96
|
};
|
|
97
|
+
|
|
98
|
+
if (args.ok) {
|
|
99
|
+
examples.toolCallExample = JSON.stringify({
|
|
100
|
+
result: {
|
|
101
|
+
action: "tool_call",
|
|
102
|
+
answer: null,
|
|
103
|
+
toolCalls: [{ toolName: firstTool?.name ?? "toolName", args: JSON.stringify(args.value) }],
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return examples;
|
|
95
109
|
}
|
|
96
110
|
|
|
97
|
-
type ExampleResult = { ok: true; value:
|
|
111
|
+
type ExampleResult = { ok: true; value: JsonValue } | { ok: false };
|
|
112
|
+
|
|
113
|
+
/** A missing tool or schema allows any object; a schema that is not JSON yields no example. */
|
|
114
|
+
function exampleArgsForTool(tool: QgridTool | undefined): ExampleResult {
|
|
115
|
+
if (tool === undefined || tool.inputSchema === undefined) return { ok: true, value: {} };
|
|
116
|
+
const inputSchema = jsonValueSchema.safeParse(tool.inputSchema);
|
|
117
|
+
|
|
118
|
+
return inputSchema.success ? exampleValueForSchema(inputSchema.data) : { ok: false };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function jsonNumber(value: JsonValue | undefined): number | undefined {
|
|
122
|
+
return z.number().safeParse(value).data;
|
|
123
|
+
}
|
|
98
124
|
|
|
99
125
|
/** 생성기가 값 선택에 반영하는 keyword. 어노테이션(description 등)은 값과 무관해 무시한다. */
|
|
100
126
|
const EXAMPLE_ANNOTATION_KEYWORDS = new Set([
|
|
@@ -107,6 +133,7 @@ const EXAMPLE_ANNOTATION_KEYWORDS = new Set([
|
|
|
107
133
|
"readOnly",
|
|
108
134
|
"writeOnly",
|
|
109
135
|
]);
|
|
136
|
+
|
|
110
137
|
const EXAMPLE_HANDLED_KEYWORDS = new Set([
|
|
111
138
|
"type",
|
|
112
139
|
"enum",
|
|
@@ -132,10 +159,11 @@ const EXAMPLE_HANDLED_KEYWORDS = new Set([
|
|
|
132
159
|
* (pattern/format/$ref/allOf/not/if/multipleOf/uniqueItems/...)을 만나면 값을
|
|
133
160
|
* 지어내지 않고 { ok: false } 를 돌려준다 — 계약 위반 예시는 모델이 베낀다.
|
|
134
161
|
*/
|
|
135
|
-
function exampleValueForSchema(schema:
|
|
162
|
+
function exampleValueForSchema(schema: JsonValue | undefined): ExampleResult {
|
|
136
163
|
if (schema === true || schema === undefined) return { ok: true, value: {} };
|
|
137
|
-
|
|
138
|
-
|
|
164
|
+
|
|
165
|
+
if (!isJsonObject(schema)) return { ok: false };
|
|
166
|
+
const node = schema;
|
|
139
167
|
|
|
140
168
|
for (const keyword of Object.keys(node)) {
|
|
141
169
|
if (!EXAMPLE_HANDLED_KEYWORDS.has(keyword) && !EXAMPLE_ANNOTATION_KEYWORDS.has(keyword)) {
|
|
@@ -143,79 +171,114 @@ function exampleValueForSchema(schema: unknown): ExampleResult {
|
|
|
143
171
|
}
|
|
144
172
|
}
|
|
145
173
|
|
|
146
|
-
|
|
147
|
-
|
|
174
|
+
const enumValues = node.enum;
|
|
175
|
+
|
|
176
|
+
if (Array.isArray(enumValues) && enumValues.length > 0) {
|
|
177
|
+
return { ok: true, value: enumValues[0] ?? null };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if ("const" in node) return { ok: true, value: node.const ?? null };
|
|
148
181
|
|
|
149
182
|
for (const kw of ["anyOf", "oneOf"] as const) {
|
|
150
|
-
|
|
183
|
+
const list = node[kw];
|
|
184
|
+
|
|
185
|
+
if (Array.isArray(list)) {
|
|
151
186
|
// oneOf 는 "정확히 하나"라 첫 브랜치 값이 다른 브랜치에도 매칭될 수 있다 —
|
|
152
187
|
// 검증기 없이 확신할 수 없으므로 브랜치가 하나일 때만 생성한다.
|
|
153
|
-
const list = node[kw] as unknown[];
|
|
154
188
|
if (kw === "oneOf" && list.length > 1) return { ok: false };
|
|
189
|
+
|
|
155
190
|
for (const branch of list) {
|
|
156
191
|
const result = exampleValueForSchema(branch);
|
|
192
|
+
|
|
157
193
|
if (result.ok) return result;
|
|
158
194
|
}
|
|
195
|
+
|
|
159
196
|
return { ok: false };
|
|
160
197
|
}
|
|
161
198
|
}
|
|
162
199
|
|
|
163
200
|
const type = Array.isArray(node.type) ? node.type[0] : node.type;
|
|
201
|
+
|
|
164
202
|
switch (type) {
|
|
165
203
|
case "string": {
|
|
166
|
-
const min =
|
|
204
|
+
const min = jsonNumber(node.minLength) ?? 0;
|
|
205
|
+
const maxLength = jsonNumber(node.maxLength);
|
|
206
|
+
|
|
167
207
|
if (min > 64) return { ok: false };
|
|
168
208
|
const base = "example";
|
|
169
209
|
const value = base.length >= min ? base : base.padEnd(min, "x");
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return { ok:
|
|
210
|
+
|
|
211
|
+
if (maxLength !== undefined && value.length > maxLength) {
|
|
212
|
+
if (maxLength < min) return { ok: false };
|
|
213
|
+
|
|
214
|
+
return { ok: true, value: value.slice(0, maxLength) };
|
|
173
215
|
}
|
|
216
|
+
|
|
174
217
|
return { ok: true, value };
|
|
175
218
|
}
|
|
219
|
+
|
|
176
220
|
case "number":
|
|
177
221
|
case "integer": {
|
|
178
222
|
let value = 0;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
223
|
+
const minimum = jsonNumber(node.minimum);
|
|
224
|
+
const exclusiveMinimum = jsonNumber(node.exclusiveMinimum);
|
|
225
|
+
const maximum = jsonNumber(node.maximum);
|
|
226
|
+
const exclusiveMaximum = jsonNumber(node.exclusiveMaximum);
|
|
227
|
+
|
|
228
|
+
if (minimum !== undefined) value = minimum;
|
|
229
|
+
else if (exclusiveMinimum !== undefined) value = exclusiveMinimum + 1;
|
|
230
|
+
|
|
231
|
+
if (maximum !== undefined && value > maximum) return { ok: false };
|
|
232
|
+
|
|
233
|
+
if (exclusiveMaximum !== undefined && value >= exclusiveMaximum) {
|
|
183
234
|
return { ok: false };
|
|
184
235
|
}
|
|
236
|
+
|
|
185
237
|
return { ok: true, value };
|
|
186
238
|
}
|
|
239
|
+
|
|
187
240
|
case "boolean":
|
|
188
241
|
return { ok: true, value: false };
|
|
189
242
|
case "null":
|
|
190
243
|
return { ok: true, value: null };
|
|
191
244
|
case "array": {
|
|
192
|
-
const min =
|
|
245
|
+
const min = jsonNumber(node.minItems) ?? 0;
|
|
246
|
+
const maxItems = jsonNumber(node.maxItems);
|
|
247
|
+
|
|
193
248
|
if (min > 8) return { ok: false };
|
|
194
|
-
|
|
249
|
+
|
|
250
|
+
if (maxItems !== undefined && maxItems < min) return { ok: false };
|
|
251
|
+
|
|
195
252
|
if (min === 0) return { ok: true, value: [] };
|
|
196
253
|
const item = exampleValueForSchema(node.items);
|
|
254
|
+
|
|
197
255
|
if (!item.ok) return { ok: false };
|
|
256
|
+
|
|
198
257
|
// 같은 값 반복이라 uniqueItems 와 충돌하지만, uniqueItems 는 지원 집합 밖이라
|
|
199
258
|
// 위의 keyword 검사에서 이미 fail-closed 된다.
|
|
200
259
|
return { ok: true, value: Array.from({ length: min }, () => item.value) };
|
|
201
260
|
}
|
|
261
|
+
|
|
202
262
|
case undefined:
|
|
203
263
|
case "object": {
|
|
204
|
-
const properties =
|
|
205
|
-
|
|
206
|
-
? (node.properties as Record<string, unknown>)
|
|
207
|
-
: {};
|
|
264
|
+
const properties: JsonObject = isJsonObject(node.properties) ? node.properties : {};
|
|
265
|
+
|
|
208
266
|
const required = Array.isArray(node.required)
|
|
209
|
-
? node.required.
|
|
267
|
+
? node.required.flatMap((key) => z.string().safeParse(key).data ?? [])
|
|
210
268
|
: [];
|
|
211
|
-
|
|
269
|
+
|
|
270
|
+
const entries: Array<[string, JsonValue]> = [];
|
|
271
|
+
|
|
212
272
|
for (const key of required) {
|
|
213
273
|
const child = exampleValueForSchema(properties[key]);
|
|
274
|
+
|
|
214
275
|
if (!child.ok) return { ok: false };
|
|
215
276
|
entries.push([key, child.value]);
|
|
216
277
|
}
|
|
278
|
+
|
|
217
279
|
return { ok: true, value: Object.fromEntries(entries) };
|
|
218
280
|
}
|
|
281
|
+
|
|
219
282
|
default:
|
|
220
283
|
return { ok: false };
|
|
221
284
|
}
|
|
@@ -230,6 +293,7 @@ export function renderToolEnvelopePrompt(tools: QgridTool[], jsonSchema?: string
|
|
|
230
293
|
const toolList = tools
|
|
231
294
|
.map((tool) => {
|
|
232
295
|
const description = tool.description ? ` — ${tool.description}` : "";
|
|
296
|
+
|
|
233
297
|
return `- ${tool.name}${description}\n inputSchema: ${JSON.stringify(tool.inputSchema)}`;
|
|
234
298
|
})
|
|
235
299
|
.join("\n");
|
|
@@ -14,12 +14,15 @@ import { getSetting } from "../setting/setting.store";
|
|
|
14
14
|
/** `토큰명:SlackUserId` 목록을 파싱한다. */
|
|
15
15
|
export function parseSlackUserMap(raw: string | undefined): Map<string, string> {
|
|
16
16
|
const map = new Map<string, string>();
|
|
17
|
+
|
|
17
18
|
if (!raw) return map;
|
|
18
19
|
|
|
19
20
|
for (const entry of raw.split(",")) {
|
|
20
21
|
const [name, userId] = entry.split(":").map((s) => s.trim());
|
|
22
|
+
|
|
21
23
|
if (name && userId) map.set(name, userId);
|
|
22
24
|
}
|
|
25
|
+
|
|
23
26
|
return map;
|
|
24
27
|
}
|
|
25
28
|
|
|
@@ -27,12 +30,14 @@ export function parseSlackUserMap(raw: string | undefined): Map<string, string>
|
|
|
27
30
|
export function ownerOf(tokenName: string | null): string {
|
|
28
31
|
if (!tokenName) return "";
|
|
29
32
|
const slash = tokenName.indexOf("/");
|
|
33
|
+
|
|
30
34
|
return slash === -1 ? tokenName : tokenName.slice(slash + 1);
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/** 매핑이 있으면 `<@U...>`, 없으면 빈 문자열. 호출부가 멘션 유무로 문구를 고른다. */
|
|
34
38
|
export function mentionFor(tokenName: string | null, userMap: Map<string, string>): string {
|
|
35
39
|
const userId = userMap.get(ownerOf(tokenName));
|
|
40
|
+
|
|
36
41
|
return userId ? `<@${userId}>` : "";
|
|
37
42
|
}
|
|
38
43
|
|
|
@@ -28,12 +28,15 @@ export async function deactivateAuthDeadToken(
|
|
|
28
28
|
token.id,
|
|
29
29
|
token.credentials,
|
|
30
30
|
);
|
|
31
|
+
|
|
31
32
|
if (staleCredentials) {
|
|
32
33
|
logger.info(
|
|
33
34
|
`skipping auth-death for ${token.name}(id=${token.id}): credentials rotated since this attempt`,
|
|
34
35
|
);
|
|
36
|
+
|
|
35
37
|
return false;
|
|
36
38
|
}
|
|
39
|
+
|
|
37
40
|
if (!marked) return false;
|
|
38
41
|
|
|
39
42
|
logger.warn(`token requires re-login: ${token.name}(id=${token.id}) reason=${reasonCode}`);
|
|
@@ -55,6 +58,7 @@ export async function deactivateAuthDeadToken(
|
|
|
55
58
|
color: SLACK_COLOR.bad,
|
|
56
59
|
urgent: wasLastActive,
|
|
57
60
|
});
|
|
61
|
+
|
|
58
62
|
return true;
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -22,7 +22,7 @@ function openaiToken(active = true) {
|
|
|
22
22
|
provider: "openai",
|
|
23
23
|
active,
|
|
24
24
|
name: "tok-A",
|
|
25
|
-
credentials: { accessToken: "access", accountId: "account" },
|
|
25
|
+
credentials: { accessToken: "access", refreshToken: "refresh", accessTokenExpiresAt: 0, accountId: "account" },
|
|
26
26
|
quota_threshold: 80,
|
|
27
27
|
weight: 4,
|
|
28
28
|
};
|
|
@@ -70,7 +70,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
70
70
|
expect(openaiDispatcher.onTokenUpdated).toHaveBeenCalledWith(
|
|
71
71
|
1,
|
|
72
72
|
"tok-A",
|
|
73
|
-
{ accessToken: "access", accountId: "account" },
|
|
73
|
+
{ accessToken: "access", refreshToken: "refresh", accessTokenExpiresAt: 0, accountId: "account" },
|
|
74
74
|
80,
|
|
75
75
|
4,
|
|
76
76
|
);
|
|
@@ -90,7 +90,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
90
90
|
findOneMock.mockResolvedValueOnce({
|
|
91
91
|
...openaiToken(true),
|
|
92
92
|
provider: "anthropic",
|
|
93
|
-
credentials: { accessToken: "access", refreshToken: "refresh" },
|
|
93
|
+
credentials: { accessToken: "access", refreshToken: "refresh", expiresAt: 0, accountUuid: "account" },
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
await subscriber.handleNotification(JSON.stringify({ op: "UPDATE", id: 1 }));
|
|
@@ -98,7 +98,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
98
98
|
expect(anthropicDispatcher.onTokenUpdated).toHaveBeenCalledWith(
|
|
99
99
|
1,
|
|
100
100
|
"tok-A",
|
|
101
|
-
{ accessToken: "access", refreshToken: "refresh" },
|
|
101
|
+
{ accessToken: "access", refreshToken: "refresh", expiresAt: 0, accountUuid: "account" },
|
|
102
102
|
80,
|
|
103
103
|
4,
|
|
104
104
|
);
|
|
@@ -120,7 +120,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
120
120
|
findOneMock.mockResolvedValueOnce({
|
|
121
121
|
...openaiToken(true),
|
|
122
122
|
provider: "anthropic",
|
|
123
|
-
credentials: { accessToken: "access", refreshToken: "refresh" },
|
|
123
|
+
credentials: { accessToken: "access", refreshToken: "refresh", expiresAt: 0, accountUuid: "account" },
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
await subscriber.handleNotification(JSON.stringify({ op: "INSERT", id: 1 }));
|
|
@@ -132,7 +132,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
132
132
|
const previous = {
|
|
133
133
|
...openaiToken(true),
|
|
134
134
|
provider: "anthropic",
|
|
135
|
-
credentials: { accessToken: "old", refreshToken: "refresh" },
|
|
135
|
+
credentials: { accessToken: "old", refreshToken: "refresh", expiresAt: 0, accountUuid: "account" },
|
|
136
136
|
};
|
|
137
137
|
const anthropicDispatcher = { onTokenUpdated: vi.fn() };
|
|
138
138
|
const subscriber = new TokenSubscriber(
|
|
@@ -148,7 +148,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
148
148
|
subscriber.tokenChangeHandler = onTokensChanged;
|
|
149
149
|
findOneMock.mockResolvedValueOnce({
|
|
150
150
|
...previous,
|
|
151
|
-
credentials: { accessToken: "new", refreshToken: "refresh" },
|
|
151
|
+
credentials: { accessToken: "new", refreshToken: "refresh", expiresAt: 0, accountUuid: "account" },
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
await subscriber.handleNotification(JSON.stringify({ op: "UPDATE", id: previous.id }));
|
|
@@ -161,7 +161,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
161
161
|
const previous = {
|
|
162
162
|
...openaiToken(true),
|
|
163
163
|
provider: "anthropic",
|
|
164
|
-
credentials: { accessToken: "access", refreshToken: "refresh" },
|
|
164
|
+
credentials: { accessToken: "access", refreshToken: "refresh", expiresAt: 0, accountUuid: "account" },
|
|
165
165
|
};
|
|
166
166
|
const subscriber = new TokenSubscriber(
|
|
167
167
|
{} as never,
|
|
@@ -182,8 +182,14 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
it("serializes token reloads so rapid weight updates cannot apply backward", async () => {
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
const anthropicToken = (weight: number) => ({
|
|
186
|
+
...openaiToken(true),
|
|
187
|
+
provider: "anthropic",
|
|
188
|
+
credentials: { accessToken: "access", refreshToken: "refresh", expiresAt: 0, accountUuid: "a" },
|
|
189
|
+
weight,
|
|
190
|
+
});
|
|
191
|
+
let resolveFirst!: (value: ReturnType<typeof anthropicToken>) => void;
|
|
192
|
+
const firstRow = new Promise<ReturnType<typeof anthropicToken>>((resolve) => {
|
|
187
193
|
resolveFirst = resolve;
|
|
188
194
|
});
|
|
189
195
|
const anthropicDispatcher = { onTokenUpdated: vi.fn() };
|
|
@@ -196,11 +202,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
196
202
|
anthropicDispatcher,
|
|
197
203
|
} as never,
|
|
198
204
|
);
|
|
199
|
-
findOneMock.mockReturnValueOnce(firstRow).mockResolvedValueOnce(
|
|
200
|
-
...openaiToken(true),
|
|
201
|
-
provider: "anthropic",
|
|
202
|
-
weight: 5,
|
|
203
|
-
});
|
|
205
|
+
findOneMock.mockReturnValueOnce(firstRow).mockResolvedValueOnce(anthropicToken(5));
|
|
204
206
|
|
|
205
207
|
const first = subscriber.handleNotification(JSON.stringify({ op: "UPDATE", id: 1 }));
|
|
206
208
|
const second = subscriber.handleNotification(JSON.stringify({ op: "UPDATE", id: 1 }));
|
|
@@ -208,7 +210,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
208
210
|
await flushPromises();
|
|
209
211
|
expect(findOneMock).toHaveBeenCalledTimes(1);
|
|
210
212
|
|
|
211
|
-
resolveFirst(
|
|
213
|
+
resolveFirst(anthropicToken(2));
|
|
212
214
|
await Promise.all([first, second]);
|
|
213
215
|
|
|
214
216
|
expect(anthropicDispatcher.onTokenUpdated.mock.calls.map((call) => call[4])).toEqual([2, 5]);
|
|
@@ -244,13 +246,13 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
244
246
|
{
|
|
245
247
|
...openaiToken(true),
|
|
246
248
|
provider: "anthropic",
|
|
247
|
-
credentials: { accessToken: "access-a", refreshToken: "refresh-a" },
|
|
249
|
+
credentials: { accessToken: "access-a", refreshToken: "refresh-a", expiresAt: 0, accountUuid: "account" },
|
|
248
250
|
},
|
|
249
251
|
{
|
|
250
252
|
...openaiToken(true),
|
|
251
253
|
id: 2,
|
|
252
254
|
name: "tok-B",
|
|
253
|
-
credentials: { accessToken: "access-b", accountId: "account-b" },
|
|
255
|
+
credentials: { accessToken: "access-b", refreshToken: "refresh", accessTokenExpiresAt: 0, accountId: "account-b" },
|
|
254
256
|
},
|
|
255
257
|
]);
|
|
256
258
|
|
|
@@ -270,7 +272,7 @@ describe("TokenSubscriber OpenAI notifications", () => {
|
|
|
270
272
|
const currentAnthropic = {
|
|
271
273
|
...openaiToken(true),
|
|
272
274
|
provider: "anthropic",
|
|
273
|
-
credentials: { accessToken: "access-a", refreshToken: "refresh-a" },
|
|
275
|
+
credentials: { accessToken: "access-a", refreshToken: "refresh-a", expiresAt: 0, accountUuid: "account" },
|
|
274
276
|
};
|
|
275
277
|
const dispatcher = {
|
|
276
278
|
tokens: new Map([[currentAnthropic.id, currentAnthropic]]),
|