@polyester/sdk 0.36.0-devnet-20261117035807 → 0.36.0-devnet-20261118141710
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/CHANGELOG.md +66 -8
- package/dist/catalogs/index.d.ts +2 -2
- package/dist/catalogs/snapshot-validation.js +10 -1
- package/dist/catalogs/snapshot-validation.js.map +1 -1
- package/dist/catalogs/zipper-catalog.d.ts +2 -0
- package/dist/catalogs/zipper-catalog.d.ts.map +1 -1
- package/dist/catalogs/zipper-catalog.js.map +1 -1
- package/dist/catalogs/zipper-supply.d.ts +2 -0
- package/dist/catalogs/zipper-supply.d.ts.map +1 -1
- package/dist/catalogs/zipper-supply.js +7 -5
- package/dist/catalogs/zipper-supply.js.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.d.ts +679 -13
- package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.js +355 -97
- package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts +33 -4
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts.map +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.js +23 -2
- package/dist/gen/alerts/v1/price_alerts_pb.js.map +1 -1
- package/dist/gen/auth/v1/activity_pb.d.ts +148 -0
- package/dist/gen/auth/v1/activity_pb.d.ts.map +1 -0
- package/dist/gen/auth/v1/activity_pb.js +40 -0
- package/dist/gen/auth/v1/activity_pb.js.map +1 -0
- package/dist/gen/auth/v1/api_keys_pb.d.ts +10 -4
- package/dist/gen/auth/v1/api_keys_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/api_keys_pb.js +3 -1
- package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +61 -5
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +23 -6
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/mfa_pb.d.ts +140 -2
- package/dist/gen/auth/v1/mfa_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/mfa_pb.js +80 -8
- package/dist/gen/auth/v1/mfa_pb.js.map +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +18 -3
- package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/policies_pb.js +18 -3
- package/dist/gen/auth/v1/policies_pb.js.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +36 -15
- package/dist/gen/auth/v1/social_verification_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.js +1 -1
- package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +15 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +6 -2
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +104 -6
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js +49 -3
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
- package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +76 -3
- package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
- package/dist/gen/chain/zipper/v1/zipper_pb.js +46 -2
- package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
- package/dist/gen/index.d.ts +3 -1
- package/dist/gen/index.js +4 -2
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +21 -139
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js +16 -17
- package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
- package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +236 -20
- package/dist/gen/ledger/read/v1/statement_export_pb.d.ts.map +1 -1
- package/dist/gen/ledger/read/v1/statement_export_pb.js +44 -10
- package/dist/gen/ledger/read/v1/statement_export_pb.js.map +1 -1
- package/dist/gen/ledger/v1/catalog_pb.d.ts +9 -1
- package/dist/gen/ledger/v1/catalog_pb.d.ts.map +1 -1
- package/dist/gen/ledger/v1/catalog_pb.js +9 -1
- package/dist/gen/ledger/v1/catalog_pb.js.map +1 -1
- package/dist/gen/marketdata/v1/asset_info_pb.d.ts +158 -7
- package/dist/gen/marketdata/v1/asset_info_pb.d.ts.map +1 -1
- package/dist/gen/marketdata/v1/asset_info_pb.js +56 -6
- package/dist/gen/marketdata/v1/asset_info_pb.js.map +1 -1
- package/dist/gen/notifications/v1/notifications_pb.d.ts +45 -6
- package/dist/gen/notifications/v1/notifications_pb.d.ts.map +1 -1
- package/dist/gen/notifications/v1/notifications_pb.js +23 -5
- package/dist/gen/notifications/v1/notifications_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +105 -29
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +14 -2
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +50 -20
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/polyester/api/options_pb.d.ts +11 -2
- package/dist/gen/polyester/api/options_pb.d.ts.map +1 -1
- package/dist/gen/polyester/api/options_pb.js +13 -3
- package/dist/gen/polyester/api/options_pb.js.map +1 -1
- package/dist/gen/privatews/v1/private_ws_pb.d.ts +13 -3
- package/dist/gen/privatews/v1/private_ws_pb.d.ts.map +1 -1
- package/dist/gen/privatews/v1/private_ws_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +126 -10
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +14 -6
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts +665 -0
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts.map +1 -0
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js +216 -0
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js.map +1 -0
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +166 -52
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js +50 -12
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
- package/dist/gen/system/v1/system_pb.d.ts +49 -2
- package/dist/gen/system/v1/system_pb.d.ts.map +1 -1
- package/dist/gen/system/v1/system_pb.js +18 -6
- package/dist/gen/system/v1/system_pb.js.map +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +150 -71
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.js +56 -34
- package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +117 -16
- package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js +45 -2
- package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/realtime/client.js +5 -1
- package/dist/realtime/client.js.map +1 -1
- package/dist/realtime/snapshot-then-stream.js +5 -3
- package/dist/realtime/snapshot-then-stream.js.map +1 -1
- package/dist/services/account-activity/account-activity.d.ts +22 -0
- package/dist/services/account-activity/account-activity.d.ts.map +1 -0
- package/dist/services/account-activity/account-activity.js +32 -0
- package/dist/services/account-activity/account-activity.js.map +1 -0
- package/dist/services/account-activity/account-activity.schemas.d.ts +78 -0
- package/dist/services/account-activity/account-activity.schemas.d.ts.map +1 -0
- package/dist/services/account-activity/account-activity.schemas.js +44 -0
- package/dist/services/account-activity/account-activity.schemas.js.map +1 -0
- package/dist/services/account-activity/account-activity.types.d.ts +2 -0
- package/dist/services/account-activity/service.d.ts +8 -0
- package/dist/services/account-activity/service.d.ts.map +1 -0
- package/dist/services/account-activity/service.js +9 -0
- package/dist/services/account-activity/service.js.map +1 -0
- package/dist/services/address-book/address-book.schemas.js +2 -2
- package/dist/services/api-keys/api-keys.schemas.js +2 -2
- package/dist/services/assistant/assistant-events.schemas.d.ts +81 -81
- package/dist/services/assistant/assistant.codecs.d.ts +7 -2
- package/dist/services/assistant/assistant.codecs.d.ts.map +1 -1
- package/dist/services/assistant/assistant.codecs.js +18 -2
- package/dist/services/assistant/assistant.codecs.js.map +1 -1
- package/dist/services/assistant/assistant.d.ts +29 -2
- package/dist/services/assistant/assistant.d.ts.map +1 -1
- package/dist/services/assistant/assistant.js +44 -2
- package/dist/services/assistant/assistant.js.map +1 -1
- package/dist/services/assistant/assistant.schemas.d.ts +111 -6
- package/dist/services/assistant/assistant.schemas.d.ts.map +1 -1
- package/dist/services/assistant/assistant.schemas.js +74 -6
- package/dist/services/assistant/assistant.schemas.js.map +1 -1
- package/dist/services/assistant/assistant.types.d.ts +3 -3
- package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts +3 -1
- package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.codecs.js.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +15 -13
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -0
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
- package/dist/services/balances/balances.d.ts +1 -13
- package/dist/services/balances/balances.d.ts.map +1 -1
- package/dist/services/balances/balances.js +1 -45
- package/dist/services/balances/balances.js.map +1 -1
- package/dist/services/balances/balances.schemas.d.ts +1 -67
- package/dist/services/balances/balances.schemas.d.ts.map +1 -1
- package/dist/services/balances/balances.schemas.js +1 -22
- package/dist/services/balances/balances.schemas.js.map +1 -1
- package/dist/services/balances/balances.types.d.ts +2 -2
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/changelog/changelog.schemas.d.ts +38 -38
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +3 -3
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +11 -11
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts.map +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.codecs.d.ts +11 -6
- package/dist/services/internal-transfers/internal-transfers.codecs.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.codecs.js +6 -6
- package/dist/services/internal-transfers/internal-transfers.codecs.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.d.ts +17 -10
- package/dist/services/internal-transfers/internal-transfers.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.js +21 -10
- package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +43 -31
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.js +23 -12
- package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.types.d.ts +2 -2
- package/dist/services/lifecycle/lifecycle.d.ts +1 -1
- package/dist/services/lifecycle/lifecycle.js +2 -3
- package/dist/services/lifecycle/lifecycle.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +40 -40
- package/dist/services/market-data/market-data.codecs.d.ts +8 -0
- package/dist/services/market-data/market-data.codecs.d.ts.map +1 -0
- package/dist/services/market-data/market-data.codecs.js +7 -1
- package/dist/services/market-data/market-data.codecs.js.map +1 -1
- package/dist/services/market-data/market-data.d.ts +3 -2
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +3 -2
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +332 -4
- package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
- package/dist/services/market-data/market-data.schemas.js +56 -8
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-data/market-data.types.d.ts +3 -2
- package/dist/services/notifications/notifications.codecs.d.ts +1 -1
- package/dist/services/notifications/notifications.codecs.d.ts.map +1 -1
- package/dist/services/notifications/notifications.codecs.js +2 -1
- package/dist/services/notifications/notifications.codecs.js.map +1 -1
- package/dist/services/notifications/notifications.d.ts +4 -2
- package/dist/services/notifications/notifications.d.ts.map +1 -1
- package/dist/services/notifications/notifications.js +4 -2
- package/dist/services/notifications/notifications.js.map +1 -1
- package/dist/services/notifications/notifications.schemas.d.ts +63 -7
- package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
- package/dist/services/notifications/notifications.schemas.js +5 -0
- package/dist/services/notifications/notifications.schemas.js.map +1 -1
- package/dist/services/orderbook/orderbook.js +3 -2
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orders/order-enums.codecs.d.ts +2 -0
- package/dist/services/orders/order-errors.schemas.d.ts +50 -5
- package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
- package/dist/services/orders/order-errors.schemas.js +13 -3
- package/dist/services/orders/order-errors.schemas.js.map +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +310 -70
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +58 -11
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +13 -13
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +1 -1
- package/dist/services/policies/shared.codecs.js +12 -6
- package/dist/services/policies/shared.codecs.js.map +1 -1
- package/dist/services/policies/shared.d.ts +1 -1
- package/dist/services/policies/shared.js +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +9 -9
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +4 -30
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/price-alerts/price-alerts.d.ts +5 -2
- package/dist/services/price-alerts/price-alerts.d.ts.map +1 -1
- package/dist/services/price-alerts/price-alerts.js +5 -2
- package/dist/services/price-alerts/price-alerts.js.map +1 -1
- package/dist/services/price-alerts/price-alerts.schemas.js +1 -1
- package/dist/services/rewards/rewards.schemas.d.ts +4 -4
- package/dist/services/social-verification/social-verification.schemas.d.ts +9 -0
- package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +9 -2
- package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
- package/dist/services/statement-exports/statement-exports.codecs.d.ts +3 -2
- package/dist/services/statement-exports/statement-exports.codecs.d.ts.map +1 -1
- package/dist/services/statement-exports/statement-exports.codecs.js +2 -1
- package/dist/services/statement-exports/statement-exports.codecs.js.map +1 -1
- package/dist/services/statement-exports/statement-exports.d.ts +25 -10
- package/dist/services/statement-exports/statement-exports.d.ts.map +1 -1
- package/dist/services/statement-exports/statement-exports.js +33 -10
- package/dist/services/statement-exports/statement-exports.js.map +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +38 -10
- package/dist/services/statement-exports/statement-exports.schemas.d.ts.map +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.js +25 -6
- package/dist/services/statement-exports/statement-exports.schemas.js.map +1 -1
- package/dist/services/statement-exports/statement-exports.types.d.ts +2 -2
- package/dist/services/subaccounts/subaccounts.codecs.js +112 -38
- package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.d.ts +2 -1
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +3 -3
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +12 -5
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +10 -3
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/system/system.d.ts +12 -1
- package/dist/services/system/system.d.ts.map +1 -1
- package/dist/services/system/system.js +5 -0
- package/dist/services/system/system.js.map +1 -1
- package/dist/services/system/system.schemas.d.ts +13 -13
- package/dist/services/system/system.types.d.ts +2 -2
- package/dist/services/trades/trades.schemas.d.ts +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.codecs.d.ts +8 -0
- package/dist/services/trading-withdraws/trading-withdraws.codecs.d.ts.map +1 -0
- package/dist/services/trading-withdraws/trading-withdraws.codecs.js +7 -1
- package/dist/services/trading-withdraws/trading-withdraws.codecs.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.d.ts +2 -1
- package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +2 -1
- package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +15 -0
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +16 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.types.d.ts +2 -1
- package/dist/services/transfers/transfers.schemas.d.ts +4 -4
- package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +10 -10
- package/dist/services/triggers/triggers-output.schemas.d.ts +170 -52
- package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.js +13 -3
- package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
- package/dist/services/triggers/triggers.codecs.d.ts +10 -0
- package/dist/services/triggers/triggers.codecs.d.ts.map +1 -0
- package/dist/services/triggers/triggers.codecs.js +7 -1
- package/dist/services/triggers/triggers.codecs.js.map +1 -1
- package/dist/services/triggers/triggers.d.ts +2 -2
- package/dist/services/triggers/triggers.js +2 -2
- package/dist/services/triggers/triggers.js.map +1 -1
- package/dist/services/zipper/zipper.d.ts.map +1 -1
- package/dist/services/zipper/zipper.js +13 -7
- package/dist/services/zipper/zipper.js.map +1 -1
- package/dist/services/zipper/zipper.schemas.d.ts +7 -2
- package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
- package/dist/services/zipper/zipper.schemas.js +29 -9
- package/dist/services/zipper/zipper.schemas.js.map +1 -1
- package/dist/services/zipper/zipper.types.d.ts +2 -2
- package/dist/shared/catalog-config.d.ts +16 -2
- package/dist/shared/catalog-config.d.ts.map +1 -1
- package/dist/shared/catalog-config.js.map +1 -1
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +27 -4
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/error-detail.d.ts +10 -0
- package/dist/shared/error-detail.d.ts.map +1 -1
- package/dist/shared/error-detail.js.map +1 -1
- package/dist/shared/error-details/auth.js +6 -0
- package/dist/shared/error-details/auth.js.map +1 -1
- package/dist/shared/errors.d.ts +5 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +3 -0
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/ledger-codes.d.ts +3 -1
- package/dist/shared/ledger-codes.d.ts.map +1 -1
- package/dist/shared/ledger-codes.js +6 -3
- package/dist/shared/ledger-codes.js.map +1 -1
- package/dist/shared/rate-limit.schemas.d.ts +1 -1
- package/dist/wired-services.d.ts.map +1 -1
- package/dist/wired-services.js +3 -1
- package/dist/wired-services.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import "../../gen/ai/v1/assistant_pb.js";
|
|
|
2
2
|
//#region src/services/assistant/assistant.codecs.d.ts
|
|
3
3
|
declare const ASSISTANT_MESSAGE_ROLE_VALUES: readonly ["user", "assistant"];
|
|
4
4
|
type AssistantMessageRole = (typeof ASSISTANT_MESSAGE_ROLE_VALUES)[number];
|
|
5
|
-
declare const ASSISTANT_FAILURE_CATEGORY_VALUES: readonly ["canceled", "budget_exceeded", "permission_denied", "model_unavailable", "unexpected_error"];
|
|
5
|
+
declare const ASSISTANT_FAILURE_CATEGORY_VALUES: readonly ["canceled", "budget_exceeded", "permission_denied", "model_unavailable", "unexpected_error", "model_key_refused", "daily_limit_reached", "assistant_paused"];
|
|
6
6
|
type AssistantFailureCategory = (typeof ASSISTANT_FAILURE_CATEGORY_VALUES)[number];
|
|
7
7
|
declare const ASSISTANT_APPROVAL_DECISION_VALUES: readonly ["approve", "reject"];
|
|
8
8
|
type AssistantApprovalDecision = (typeof ASSISTANT_APPROVAL_DECISION_VALUES)[number];
|
|
@@ -21,6 +21,11 @@ type AssistantKeyState = (typeof ASSISTANT_KEY_STATE_VALUES)[number];
|
|
|
21
21
|
*/
|
|
22
22
|
declare const ASSISTANT_DISPLAY_SETTING_VALUES: readonly ["appearance", "language", "currency", "date_format", "time_format", "number_format", "week_start", "sounds"];
|
|
23
23
|
type AssistantDisplaySetting = (typeof ASSISTANT_DISPLAY_SETTING_VALUES)[number];
|
|
24
|
+
declare const ASSISTANT_MODEL_KEY_CHECK_VALUES: readonly ["valid", "rejected", "no_quota", "model_unavailable"];
|
|
25
|
+
type AssistantModelKeyCheck = (typeof ASSISTANT_MODEL_KEY_CHECK_VALUES)[number];
|
|
26
|
+
declare const ASSISTANT_FUNDING_MODE_VALUES: readonly ["credits", "own_key"];
|
|
27
|
+
/** What pays for the caller's next messages: free daily `credits`, or their `own_key`. */
|
|
28
|
+
type AssistantFundingMode = (typeof ASSISTANT_FUNDING_MODE_VALUES)[number];
|
|
24
29
|
declare const ASSISTANT_ACCOUNT_SELECTION_VALUES: readonly ["none"];
|
|
25
30
|
/** `"none"`: the run reads no account and answers about the markets and Polyester only. */
|
|
26
31
|
type AssistantAccountSelection = (typeof ASSISTANT_ACCOUNT_SELECTION_VALUES)[number];
|
|
@@ -35,5 +40,5 @@ type AssistantPriceRounding = "down" | "up";
|
|
|
35
40
|
type AssistantUnfilledSlicePolicy = "cancel_before_next";
|
|
36
41
|
type AssistantTriggerChangeAction = "modify" | "pause" | "resume";
|
|
37
42
|
//#endregion
|
|
38
|
-
export { ASSISTANT_ACCOUNT_SELECTION_VALUES, ASSISTANT_APPROVAL_DECISION_VALUES, ASSISTANT_APPROVAL_STATUS_VALUES, ASSISTANT_DISPLAY_SETTING_VALUES, ASSISTANT_FAILURE_CATEGORY_VALUES, ASSISTANT_KEY_STATE_VALUES, ASSISTANT_KEY_VIEW_VALUES, ASSISTANT_MEMORY_KIND_VALUES, ASSISTANT_MESSAGE_ROLE_VALUES, AssistantAccountSelection, AssistantApprovalDecision, AssistantApprovalStatus, AssistantDisplaySetting, AssistantFailureCategory, AssistantKeyState, AssistantKeyView, AssistantMemoryKind, AssistantMessageRole, AssistantOrderPriceField, AssistantPriceOffsetDirection, AssistantPriceRounding, AssistantReferencePriceSource, AssistantTriggerChangeAction, AssistantTriggerDirection, AssistantUnfilledSlicePolicy };
|
|
43
|
+
export { ASSISTANT_ACCOUNT_SELECTION_VALUES, ASSISTANT_APPROVAL_DECISION_VALUES, ASSISTANT_APPROVAL_STATUS_VALUES, ASSISTANT_DISPLAY_SETTING_VALUES, ASSISTANT_FAILURE_CATEGORY_VALUES, ASSISTANT_FUNDING_MODE_VALUES, ASSISTANT_KEY_STATE_VALUES, ASSISTANT_KEY_VIEW_VALUES, ASSISTANT_MEMORY_KIND_VALUES, ASSISTANT_MESSAGE_ROLE_VALUES, ASSISTANT_MODEL_KEY_CHECK_VALUES, AssistantAccountSelection, AssistantApprovalDecision, AssistantApprovalStatus, AssistantDisplaySetting, AssistantFailureCategory, AssistantFundingMode, AssistantKeyState, AssistantKeyView, AssistantMemoryKind, AssistantMessageRole, AssistantModelKeyCheck, AssistantOrderPriceField, AssistantPriceOffsetDirection, AssistantPriceRounding, AssistantReferencePriceSource, AssistantTriggerChangeAction, AssistantTriggerDirection, AssistantUnfilledSlicePolicy };
|
|
39
44
|
//# sourceMappingURL=assistant.codecs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.codecs.d.ts","names":[],"sources":["../../../src/services/assistant/assistant.codecs.ts"],"mappings":";;cAGa;KACD,+BAA+B;cAE9B;
|
|
1
|
+
{"version":3,"file":"assistant.codecs.d.ts","names":[],"sources":["../../../src/services/assistant/assistant.codecs.ts"],"mappings":";;cAGa;KACD,+BAA+B;cAE9B;KAUD,mCAAmC;cAElC;KACD,oCAAoC;cAEnC;KAMD,kCAAkC;cAEjC;KACD,8BAA8B;cAE7B;KACD,4BAA4B;;;;;;;;cAS3B;KAUD,kCAAkC;cAEjC;KAMD,iCAAiC;cAEhC;;KAED,+BAA+B;cAE9B;;KAED,oCAAoC;cAQnC;;KAED,2BAA2B;KAgC3B;KACA;KACA;KAYA;KACA;KACA;KACA"}
|
|
@@ -56,7 +56,23 @@ const FailureCategoryCodec = { protoToOutput: {
|
|
|
56
56
|
[2]: "budget_exceeded",
|
|
57
57
|
[3]: "permission_denied",
|
|
58
58
|
[4]: "model_unavailable",
|
|
59
|
-
[5]: "unexpected_error"
|
|
59
|
+
[5]: "unexpected_error",
|
|
60
|
+
[6]: "model_key_refused",
|
|
61
|
+
[7]: "daily_limit_reached",
|
|
62
|
+
[8]: "assistant_paused"
|
|
63
|
+
} };
|
|
64
|
+
const ModelKeyCheckCodec = { protoToOutput: {
|
|
65
|
+
[0]: "unspecified",
|
|
66
|
+
[1]: "valid",
|
|
67
|
+
[2]: "rejected",
|
|
68
|
+
[3]: "no_quota",
|
|
69
|
+
[4]: "model_unavailable"
|
|
70
|
+
} };
|
|
71
|
+
/** The contract says to read a mode this build does not know as `credits`. */
|
|
72
|
+
const FundingModeCodec = { protoToOutput: {
|
|
73
|
+
[0]: "credits",
|
|
74
|
+
[1]: "credits",
|
|
75
|
+
[2]: "own_key"
|
|
60
76
|
} };
|
|
61
77
|
const ApprovalDecisionCodec = { inputToProto: {
|
|
62
78
|
approve: 1,
|
|
@@ -127,6 +143,6 @@ const TriggerChangeActionCodec = { protoToOutput: {
|
|
|
127
143
|
[3]: "resume"
|
|
128
144
|
} };
|
|
129
145
|
//#endregion
|
|
130
|
-
export { ASSISTANT_ACCOUNT_SELECTION_VALUES, ASSISTANT_APPROVAL_DECISION_VALUES, ASSISTANT_DISPLAY_SETTING_VALUES, ASSISTANT_KEY_VIEW_VALUES, AccountSelectionCodec, ApprovalDecisionCodec, ApprovalStatusCodec, AssistantKeyStateCodec, AssistantKeyViewCodec, DisplaySettingCodec, FailureCategoryCodec, MemoryKindCodec, MessageRoleCodec, OrderPriceFieldCodec, PriceOffsetDirectionCodec, PriceRoundingCodec, ReferencePriceSourceCodec, TriggerChangeActionCodec, TriggerDirectionCodec, UnfilledSlicePolicyCodec };
|
|
146
|
+
export { ASSISTANT_ACCOUNT_SELECTION_VALUES, ASSISTANT_APPROVAL_DECISION_VALUES, ASSISTANT_DISPLAY_SETTING_VALUES, ASSISTANT_KEY_VIEW_VALUES, AccountSelectionCodec, ApprovalDecisionCodec, ApprovalStatusCodec, AssistantKeyStateCodec, AssistantKeyViewCodec, DisplaySettingCodec, FailureCategoryCodec, FundingModeCodec, MemoryKindCodec, MessageRoleCodec, ModelKeyCheckCodec, OrderPriceFieldCodec, PriceOffsetDirectionCodec, PriceRoundingCodec, ReferencePriceSourceCodec, TriggerChangeActionCodec, TriggerDirectionCodec, UnfilledSlicePolicyCodec };
|
|
131
147
|
|
|
132
148
|
//# sourceMappingURL=assistant.codecs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.codecs.js","names":[],"sources":["../../../src/services/assistant/assistant.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/ai/v1/assistant_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const ASSISTANT_MESSAGE_ROLE_VALUES = [\"user\", \"assistant\"] as const;\nexport type AssistantMessageRole = (typeof ASSISTANT_MESSAGE_ROLE_VALUES)[number];\n\nexport const ASSISTANT_FAILURE_CATEGORY_VALUES = [\n \"canceled\",\n \"budget_exceeded\",\n \"permission_denied\",\n \"model_unavailable\",\n \"unexpected_error\",\n] as const;\nexport type AssistantFailureCategory = (typeof ASSISTANT_FAILURE_CATEGORY_VALUES)[number];\n\nexport const ASSISTANT_APPROVAL_DECISION_VALUES = [\"approve\", \"reject\"] as const;\nexport type AssistantApprovalDecision = (typeof ASSISTANT_APPROVAL_DECISION_VALUES)[number];\n\nexport const ASSISTANT_APPROVAL_STATUS_VALUES = [\n \"pending\",\n \"approved\",\n \"rejected\",\n \"expired\",\n] as const;\nexport type AssistantApprovalStatus = (typeof ASSISTANT_APPROVAL_STATUS_VALUES)[number];\n\nexport const ASSISTANT_MEMORY_KIND_VALUES = [\"fact\", \"planning_figure\", \"profile\"] as const;\nexport type AssistantMemoryKind = (typeof ASSISTANT_MEMORY_KIND_VALUES)[number];\n\nexport const ASSISTANT_KEY_STATE_VALUES = [\"active\", \"disabled\"] as const;\nexport type AssistantKeyState = (typeof ASSISTANT_KEY_STATE_VALUES)[number];\n\n/**\n * Display preferences a client lets the assistant change: `appearance` (`light`, `dark`,\n * `system`), `language` (`en`, `fr`, `zh-CN`), `currency` (a fiat code such as `EUR`),\n * `date_format` (a pattern such as `yyyy-MM-dd`), `time_format` (`12h`, `24h`), `number_format`\n * (`US`, `EU`, `SPACE`, `CH`, `IN`, `NONE`), `week_start` (`0` Sunday to `6` Saturday) and\n * `sounds` (`on`, `off`).\n */\nexport const ASSISTANT_DISPLAY_SETTING_VALUES = [\n \"appearance\",\n \"language\",\n \"currency\",\n \"date_format\",\n \"time_format\",\n \"number_format\",\n \"week_start\",\n \"sounds\",\n] as const;\nexport type AssistantDisplaySetting = (typeof ASSISTANT_DISPLAY_SETTING_VALUES)[number];\n\nexport const ASSISTANT_ACCOUNT_SELECTION_VALUES = [\"none\"] as const;\n/** `\"none\"`: the run reads no account and answers about the markets and Polyester only. */\nexport type AssistantAccountSelection = (typeof ASSISTANT_ACCOUNT_SELECTION_VALUES)[number];\n\nexport const AccountSelectionCodec = {\n inputToProto: {\n none: Proto.AccountSelection.NONE,\n } satisfies InputToProto<AssistantAccountSelection, Proto.AccountSelection>,\n} as const;\n\nexport const ASSISTANT_KEY_VIEW_VALUES = [\"full\"] as const;\n/** `\"full\"` adds each key's account name (`label`). */\nexport type AssistantKeyView = (typeof ASSISTANT_KEY_VIEW_VALUES)[number];\n\nexport const AssistantKeyViewCodec = {\n inputToProto: {\n full: Proto.AssistantKeyView.FULL,\n } satisfies InputToProto<AssistantKeyView, Proto.AssistantKeyView>,\n} as const;\n\nexport const DisplaySettingCodec = {\n inputToProto: {\n appearance: Proto.DisplaySetting.APPEARANCE,\n language: Proto.DisplaySetting.LANGUAGE,\n currency: Proto.DisplaySetting.CURRENCY,\n date_format: Proto.DisplaySetting.DATE_FORMAT,\n time_format: Proto.DisplaySetting.TIME_FORMAT,\n number_format: Proto.DisplaySetting.NUMBER_FORMAT,\n week_start: Proto.DisplaySetting.WEEK_START,\n sounds: Proto.DisplaySetting.SOUNDS,\n } satisfies InputToProto<AssistantDisplaySetting, Proto.DisplaySetting>,\n protoToOutput: {\n [Proto.DisplaySetting.SETTING_UNSPECIFIED]: \"unspecified\",\n [Proto.DisplaySetting.APPEARANCE]: \"appearance\",\n [Proto.DisplaySetting.LANGUAGE]: \"language\",\n [Proto.DisplaySetting.CURRENCY]: \"currency\",\n [Proto.DisplaySetting.DATE_FORMAT]: \"date_format\",\n [Proto.DisplaySetting.TIME_FORMAT]: \"time_format\",\n [Proto.DisplaySetting.NUMBER_FORMAT]: \"number_format\",\n [Proto.DisplaySetting.WEEK_START]: \"week_start\",\n [Proto.DisplaySetting.SOUNDS]: \"sounds\",\n } satisfies ProtoToOutput<Proto.DisplaySetting, AssistantDisplaySetting>,\n} as const;\n\nexport type AssistantReferencePriceSource = \"best_bid\" | \"best_ask\" | \"last_price\" | \"index_price\";\nexport type AssistantTriggerDirection = \"at_or_above\" | \"at_or_below\";\nexport type AssistantOrderPriceField =\n | \"limit_price\"\n | \"trigger_price\"\n | \"activation_price\"\n | \"ladder_low_price\"\n | \"ladder_high_price\"\n | \"take_profit_trigger_price\"\n | \"take_profit_limit_price\"\n | \"stop_loss_trigger_price\"\n | \"stop_loss_limit_price\"\n | \"trailing_stop_activation_price\"\n | \"trailing_stop_limit_price\";\nexport type AssistantPriceOffsetDirection = \"above\" | \"below\";\nexport type AssistantPriceRounding = \"down\" | \"up\";\nexport type AssistantUnfilledSlicePolicy = \"cancel_before_next\";\nexport type AssistantTriggerChangeAction = \"modify\" | \"pause\" | \"resume\";\n\nexport const MessageRoleCodec = {\n protoToOutput: {\n [Proto.MessageRole.ROLE_UNSPECIFIED]: \"unspecified\",\n [Proto.MessageRole.USER]: \"user\",\n [Proto.MessageRole.ASSISTANT]: \"assistant\",\n } satisfies ProtoToOutput<Proto.MessageRole, AssistantMessageRole>,\n} as const;\n\nexport const FailureCategoryCodec = {\n protoToOutput: {\n [Proto.FailureCategory.FAILURE_UNSPECIFIED]: \"unspecified\",\n [Proto.FailureCategory.CANCELLED]: \"canceled\",\n [Proto.FailureCategory.BUDGET_EXCEEDED]: \"budget_exceeded\",\n [Proto.FailureCategory.PERMISSION_DENIED]: \"permission_denied\",\n [Proto.FailureCategory.MODEL_UNAVAILABLE]: \"model_unavailable\",\n [Proto.FailureCategory.UNEXPECTED_ERROR]: \"unexpected_error\",\n } satisfies ProtoToOutput<Proto.FailureCategory, AssistantFailureCategory>,\n} as const;\n\nexport const ApprovalDecisionCodec = {\n inputToProto: {\n approve: Proto.ApprovalDecision.APPROVE,\n reject: Proto.ApprovalDecision.REJECT,\n } satisfies InputToProto<AssistantApprovalDecision, Proto.ApprovalDecision>,\n} as const;\n\nexport const ApprovalStatusCodec = {\n protoToOutput: {\n [Proto.ApprovalStatus.APPROVAL_UNSPECIFIED]: \"unspecified\",\n [Proto.ApprovalStatus.PENDING]: \"pending\",\n [Proto.ApprovalStatus.APPROVED]: \"approved\",\n [Proto.ApprovalStatus.REJECTED]: \"rejected\",\n [Proto.ApprovalStatus.EXPIRED]: \"expired\",\n } satisfies ProtoToOutput<Proto.ApprovalStatus, AssistantApprovalStatus>,\n} as const;\n\nexport const MemoryKindCodec = {\n protoToOutput: {\n [Proto.MemoryKind.KIND_UNSPECIFIED]: \"unspecified\",\n [Proto.MemoryKind.FACT]: \"fact\",\n [Proto.MemoryKind.PLANNING_FIGURE]: \"planning_figure\",\n [Proto.MemoryKind.PROFILE]: \"profile\",\n } satisfies ProtoToOutput<Proto.MemoryKind, AssistantMemoryKind>,\n} as const;\n\nexport const AssistantKeyStateCodec = {\n protoToOutput: {\n [Proto.AssistantKeyState.KEY_STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.AssistantKeyState.ACTIVE]: \"active\",\n [Proto.AssistantKeyState.DISABLED]: \"disabled\",\n } satisfies ProtoToOutput<Proto.AssistantKeyState, AssistantKeyState>,\n} as const;\n\nexport const ReferencePriceSourceCodec = {\n protoToOutput: {\n [Proto.ReferencePriceSource.PRICE_SOURCE_UNSPECIFIED]: \"unspecified\",\n [Proto.ReferencePriceSource.BEST_BID]: \"best_bid\",\n [Proto.ReferencePriceSource.BEST_ASK]: \"best_ask\",\n [Proto.ReferencePriceSource.LAST_PRICE]: \"last_price\",\n [Proto.ReferencePriceSource.INDEX_PRICE]: \"index_price\",\n } satisfies ProtoToOutput<Proto.ReferencePriceSource, AssistantReferencePriceSource>,\n} as const;\n\nexport const TriggerDirectionCodec = {\n protoToOutput: {\n [Proto.TriggerDirection.DIRECTION_UNSPECIFIED]: \"unspecified\",\n [Proto.TriggerDirection.AT_OR_ABOVE]: \"at_or_above\",\n [Proto.TriggerDirection.AT_OR_BELOW]: \"at_or_below\",\n } satisfies ProtoToOutput<Proto.TriggerDirection, AssistantTriggerDirection>,\n} as const;\n\nexport const OrderPriceFieldCodec = {\n protoToOutput: {\n [Proto.OrderPriceField.PRICE_FIELD_UNSPECIFIED]: \"unspecified\",\n [Proto.OrderPriceField.LIMIT_PRICE]: \"limit_price\",\n [Proto.OrderPriceField.TRIGGER_PRICE]: \"trigger_price\",\n [Proto.OrderPriceField.ACTIVATION_PRICE]: \"activation_price\",\n [Proto.OrderPriceField.LADDER_LOW_PRICE]: \"ladder_low_price\",\n [Proto.OrderPriceField.LADDER_HIGH_PRICE]: \"ladder_high_price\",\n [Proto.OrderPriceField.TAKE_PROFIT_TRIGGER_PRICE]: \"take_profit_trigger_price\",\n [Proto.OrderPriceField.TAKE_PROFIT_LIMIT_PRICE]: \"take_profit_limit_price\",\n [Proto.OrderPriceField.STOP_LOSS_TRIGGER_PRICE]: \"stop_loss_trigger_price\",\n [Proto.OrderPriceField.STOP_LOSS_LIMIT_PRICE]: \"stop_loss_limit_price\",\n [Proto.OrderPriceField.TRAILING_STOP_ACTIVATION_PRICE]: \"trailing_stop_activation_price\",\n [Proto.OrderPriceField.TRAILING_STOP_LIMIT_PRICE]: \"trailing_stop_limit_price\",\n } satisfies ProtoToOutput<Proto.OrderPriceField, AssistantOrderPriceField>,\n} as const;\n\nexport const PriceOffsetDirectionCodec = {\n protoToOutput: {\n [Proto.PriceOffsetDirection.OFFSET_DIRECTION_UNSPECIFIED]: \"unspecified\",\n [Proto.PriceOffsetDirection.ABOVE]: \"above\",\n [Proto.PriceOffsetDirection.BELOW]: \"below\",\n } satisfies ProtoToOutput<Proto.PriceOffsetDirection, AssistantPriceOffsetDirection>,\n} as const;\n\nexport const PriceRoundingCodec = {\n protoToOutput: {\n [Proto.PriceRounding.ROUNDING_UNSPECIFIED]: \"unspecified\",\n [Proto.PriceRounding.DOWN]: \"down\",\n [Proto.PriceRounding.UP]: \"up\",\n } satisfies ProtoToOutput<Proto.PriceRounding, AssistantPriceRounding>,\n} as const;\n\nexport const UnfilledSlicePolicyCodec = {\n protoToOutput: {\n [Proto.UnfilledSlicePolicy.UNFILLED_SLICE_UNSPECIFIED]: \"unspecified\",\n [Proto.UnfilledSlicePolicy.CANCEL_BEFORE_NEXT]: \"cancel_before_next\",\n } satisfies ProtoToOutput<Proto.UnfilledSlicePolicy, AssistantUnfilledSlicePolicy>,\n} as const;\n\nexport const TriggerChangeActionCodec = {\n protoToOutput: {\n [Proto.TriggerChangeAction.TRIGGER_CHANGE_UNSPECIFIED]: \"unspecified\",\n [Proto.TriggerChangeAction.MODIFY]: \"modify\",\n [Proto.TriggerChangeAction.PAUSE]: \"pause\",\n [Proto.TriggerChangeAction.RESUME]: \"resume\",\n } satisfies ProtoToOutput<Proto.TriggerChangeAction, AssistantTriggerChangeAction>,\n} as const;\n"],"mappings":";;AAeA,MAAa,qCAAqC,CAAC,WAAW,QAAQ;;;;;;;;AAwBtE,MAAa,mCAAmC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAGA,MAAa,qCAAqC,CAAC,MAAM;AAIzD,MAAa,wB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,IAAA;EACS,KAAA;EACL,KAAA;AACvD,EACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EACgD,IAAA;EACvB,IAAA;EACA,IAAA;AACxC,EACJ;AAEA,MAAa,qBAAqB,EAC9B,eAAe;EACiC,IAAA;EAChB,IAAA;EACF,IAAA;AAC9B,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC6C,IAAA;EACR,IAAA;AACpD,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC6C,IAAA;EACpB,IAAA;EACD,IAAA;EACC,IAAA;AACxC,EACJ"}
|
|
1
|
+
{"version":3,"file":"assistant.codecs.js","names":[],"sources":["../../../src/services/assistant/assistant.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/ai/v1/assistant_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const ASSISTANT_MESSAGE_ROLE_VALUES = [\"user\", \"assistant\"] as const;\nexport type AssistantMessageRole = (typeof ASSISTANT_MESSAGE_ROLE_VALUES)[number];\n\nexport const ASSISTANT_FAILURE_CATEGORY_VALUES = [\n \"canceled\",\n \"budget_exceeded\",\n \"permission_denied\",\n \"model_unavailable\",\n \"unexpected_error\",\n \"model_key_refused\",\n \"daily_limit_reached\",\n \"assistant_paused\",\n] as const;\nexport type AssistantFailureCategory = (typeof ASSISTANT_FAILURE_CATEGORY_VALUES)[number];\n\nexport const ASSISTANT_APPROVAL_DECISION_VALUES = [\"approve\", \"reject\"] as const;\nexport type AssistantApprovalDecision = (typeof ASSISTANT_APPROVAL_DECISION_VALUES)[number];\n\nexport const ASSISTANT_APPROVAL_STATUS_VALUES = [\n \"pending\",\n \"approved\",\n \"rejected\",\n \"expired\",\n] as const;\nexport type AssistantApprovalStatus = (typeof ASSISTANT_APPROVAL_STATUS_VALUES)[number];\n\nexport const ASSISTANT_MEMORY_KIND_VALUES = [\"fact\", \"planning_figure\", \"profile\"] as const;\nexport type AssistantMemoryKind = (typeof ASSISTANT_MEMORY_KIND_VALUES)[number];\n\nexport const ASSISTANT_KEY_STATE_VALUES = [\"active\", \"disabled\"] as const;\nexport type AssistantKeyState = (typeof ASSISTANT_KEY_STATE_VALUES)[number];\n\n/**\n * Display preferences a client lets the assistant change: `appearance` (`light`, `dark`,\n * `system`), `language` (`en`, `fr`, `zh-CN`), `currency` (a fiat code such as `EUR`),\n * `date_format` (a pattern such as `yyyy-MM-dd`), `time_format` (`12h`, `24h`), `number_format`\n * (`US`, `EU`, `SPACE`, `CH`, `IN`, `NONE`), `week_start` (`0` Sunday to `6` Saturday) and\n * `sounds` (`on`, `off`).\n */\nexport const ASSISTANT_DISPLAY_SETTING_VALUES = [\n \"appearance\",\n \"language\",\n \"currency\",\n \"date_format\",\n \"time_format\",\n \"number_format\",\n \"week_start\",\n \"sounds\",\n] as const;\nexport type AssistantDisplaySetting = (typeof ASSISTANT_DISPLAY_SETTING_VALUES)[number];\n\nexport const ASSISTANT_MODEL_KEY_CHECK_VALUES = [\n \"valid\",\n \"rejected\",\n \"no_quota\",\n \"model_unavailable\",\n] as const;\nexport type AssistantModelKeyCheck = (typeof ASSISTANT_MODEL_KEY_CHECK_VALUES)[number];\n\nexport const ASSISTANT_FUNDING_MODE_VALUES = [\"credits\", \"own_key\"] as const;\n/** What pays for the caller's next messages: free daily `credits`, or their `own_key`. */\nexport type AssistantFundingMode = (typeof ASSISTANT_FUNDING_MODE_VALUES)[number];\n\nexport const ASSISTANT_ACCOUNT_SELECTION_VALUES = [\"none\"] as const;\n/** `\"none\"`: the run reads no account and answers about the markets and Polyester only. */\nexport type AssistantAccountSelection = (typeof ASSISTANT_ACCOUNT_SELECTION_VALUES)[number];\n\nexport const AccountSelectionCodec = {\n inputToProto: {\n none: Proto.AccountSelection.NONE,\n } satisfies InputToProto<AssistantAccountSelection, Proto.AccountSelection>,\n} as const;\n\nexport const ASSISTANT_KEY_VIEW_VALUES = [\"full\"] as const;\n/** `\"full\"` adds each key's account name (`label`). */\nexport type AssistantKeyView = (typeof ASSISTANT_KEY_VIEW_VALUES)[number];\n\nexport const AssistantKeyViewCodec = {\n inputToProto: {\n full: Proto.AssistantKeyView.FULL,\n } satisfies InputToProto<AssistantKeyView, Proto.AssistantKeyView>,\n} as const;\n\nexport const DisplaySettingCodec = {\n inputToProto: {\n appearance: Proto.DisplaySetting.APPEARANCE,\n language: Proto.DisplaySetting.LANGUAGE,\n currency: Proto.DisplaySetting.CURRENCY,\n date_format: Proto.DisplaySetting.DATE_FORMAT,\n time_format: Proto.DisplaySetting.TIME_FORMAT,\n number_format: Proto.DisplaySetting.NUMBER_FORMAT,\n week_start: Proto.DisplaySetting.WEEK_START,\n sounds: Proto.DisplaySetting.SOUNDS,\n } satisfies InputToProto<AssistantDisplaySetting, Proto.DisplaySetting>,\n protoToOutput: {\n [Proto.DisplaySetting.SETTING_UNSPECIFIED]: \"unspecified\",\n [Proto.DisplaySetting.APPEARANCE]: \"appearance\",\n [Proto.DisplaySetting.LANGUAGE]: \"language\",\n [Proto.DisplaySetting.CURRENCY]: \"currency\",\n [Proto.DisplaySetting.DATE_FORMAT]: \"date_format\",\n [Proto.DisplaySetting.TIME_FORMAT]: \"time_format\",\n [Proto.DisplaySetting.NUMBER_FORMAT]: \"number_format\",\n [Proto.DisplaySetting.WEEK_START]: \"week_start\",\n [Proto.DisplaySetting.SOUNDS]: \"sounds\",\n } satisfies ProtoToOutput<Proto.DisplaySetting, AssistantDisplaySetting>,\n} as const;\n\nexport type AssistantReferencePriceSource = \"best_bid\" | \"best_ask\" | \"last_price\" | \"index_price\";\nexport type AssistantTriggerDirection = \"at_or_above\" | \"at_or_below\";\nexport type AssistantOrderPriceField =\n | \"limit_price\"\n | \"trigger_price\"\n | \"activation_price\"\n | \"ladder_low_price\"\n | \"ladder_high_price\"\n | \"take_profit_trigger_price\"\n | \"take_profit_limit_price\"\n | \"stop_loss_trigger_price\"\n | \"stop_loss_limit_price\"\n | \"trailing_stop_activation_price\"\n | \"trailing_stop_limit_price\";\nexport type AssistantPriceOffsetDirection = \"above\" | \"below\";\nexport type AssistantPriceRounding = \"down\" | \"up\";\nexport type AssistantUnfilledSlicePolicy = \"cancel_before_next\";\nexport type AssistantTriggerChangeAction = \"modify\" | \"pause\" | \"resume\";\n\nexport const MessageRoleCodec = {\n protoToOutput: {\n [Proto.MessageRole.ROLE_UNSPECIFIED]: \"unspecified\",\n [Proto.MessageRole.USER]: \"user\",\n [Proto.MessageRole.ASSISTANT]: \"assistant\",\n } satisfies ProtoToOutput<Proto.MessageRole, AssistantMessageRole>,\n} as const;\n\nexport const FailureCategoryCodec = {\n protoToOutput: {\n [Proto.FailureCategory.FAILURE_UNSPECIFIED]: \"unspecified\",\n [Proto.FailureCategory.CANCELLED]: \"canceled\",\n [Proto.FailureCategory.BUDGET_EXCEEDED]: \"budget_exceeded\",\n [Proto.FailureCategory.PERMISSION_DENIED]: \"permission_denied\",\n [Proto.FailureCategory.MODEL_UNAVAILABLE]: \"model_unavailable\",\n [Proto.FailureCategory.UNEXPECTED_ERROR]: \"unexpected_error\",\n [Proto.FailureCategory.MODEL_KEY_REFUSED]: \"model_key_refused\",\n [Proto.FailureCategory.DAILY_LIMIT_REACHED]: \"daily_limit_reached\",\n [Proto.FailureCategory.ASSISTANT_PAUSED]: \"assistant_paused\",\n } satisfies ProtoToOutput<Proto.FailureCategory, AssistantFailureCategory>,\n} as const;\n\nexport const ModelKeyCheckCodec = {\n protoToOutput: {\n [Proto.ModelKeyCheck.KEY_CHECK_UNSPECIFIED]: \"unspecified\",\n [Proto.ModelKeyCheck.KEY_VALID]: \"valid\",\n [Proto.ModelKeyCheck.KEY_REJECTED]: \"rejected\",\n [Proto.ModelKeyCheck.KEY_NO_QUOTA]: \"no_quota\",\n [Proto.ModelKeyCheck.KEY_MODEL_UNAVAILABLE]: \"model_unavailable\",\n } satisfies ProtoToOutput<Proto.ModelKeyCheck, AssistantModelKeyCheck>,\n} as const;\n\n/** The contract says to read a mode this build does not know as `credits`. */\nexport const FundingModeCodec = {\n protoToOutput: {\n [Proto.FundingMode.FUNDING_UNSPECIFIED]: \"credits\",\n [Proto.FundingMode.CREDITS]: \"credits\",\n [Proto.FundingMode.OWN_KEY]: \"own_key\",\n } satisfies ProtoToOutput<Proto.FundingMode, AssistantFundingMode>,\n} as const;\n\nexport const ApprovalDecisionCodec = {\n inputToProto: {\n approve: Proto.ApprovalDecision.APPROVE,\n reject: Proto.ApprovalDecision.REJECT,\n } satisfies InputToProto<AssistantApprovalDecision, Proto.ApprovalDecision>,\n} as const;\n\nexport const ApprovalStatusCodec = {\n protoToOutput: {\n [Proto.ApprovalStatus.APPROVAL_UNSPECIFIED]: \"unspecified\",\n [Proto.ApprovalStatus.PENDING]: \"pending\",\n [Proto.ApprovalStatus.APPROVED]: \"approved\",\n [Proto.ApprovalStatus.REJECTED]: \"rejected\",\n [Proto.ApprovalStatus.EXPIRED]: \"expired\",\n } satisfies ProtoToOutput<Proto.ApprovalStatus, AssistantApprovalStatus>,\n} as const;\n\nexport const MemoryKindCodec = {\n protoToOutput: {\n [Proto.MemoryKind.KIND_UNSPECIFIED]: \"unspecified\",\n [Proto.MemoryKind.FACT]: \"fact\",\n [Proto.MemoryKind.PLANNING_FIGURE]: \"planning_figure\",\n [Proto.MemoryKind.PROFILE]: \"profile\",\n } satisfies ProtoToOutput<Proto.MemoryKind, AssistantMemoryKind>,\n} as const;\n\nexport const AssistantKeyStateCodec = {\n protoToOutput: {\n [Proto.AssistantKeyState.KEY_STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.AssistantKeyState.ACTIVE]: \"active\",\n [Proto.AssistantKeyState.DISABLED]: \"disabled\",\n } satisfies ProtoToOutput<Proto.AssistantKeyState, AssistantKeyState>,\n} as const;\n\nexport const ReferencePriceSourceCodec = {\n protoToOutput: {\n [Proto.ReferencePriceSource.PRICE_SOURCE_UNSPECIFIED]: \"unspecified\",\n [Proto.ReferencePriceSource.BEST_BID]: \"best_bid\",\n [Proto.ReferencePriceSource.BEST_ASK]: \"best_ask\",\n [Proto.ReferencePriceSource.LAST_PRICE]: \"last_price\",\n [Proto.ReferencePriceSource.INDEX_PRICE]: \"index_price\",\n } satisfies ProtoToOutput<Proto.ReferencePriceSource, AssistantReferencePriceSource>,\n} as const;\n\nexport const TriggerDirectionCodec = {\n protoToOutput: {\n [Proto.TriggerDirection.DIRECTION_UNSPECIFIED]: \"unspecified\",\n [Proto.TriggerDirection.AT_OR_ABOVE]: \"at_or_above\",\n [Proto.TriggerDirection.AT_OR_BELOW]: \"at_or_below\",\n } satisfies ProtoToOutput<Proto.TriggerDirection, AssistantTriggerDirection>,\n} as const;\n\nexport const OrderPriceFieldCodec = {\n protoToOutput: {\n [Proto.OrderPriceField.PRICE_FIELD_UNSPECIFIED]: \"unspecified\",\n [Proto.OrderPriceField.LIMIT_PRICE]: \"limit_price\",\n [Proto.OrderPriceField.TRIGGER_PRICE]: \"trigger_price\",\n [Proto.OrderPriceField.ACTIVATION_PRICE]: \"activation_price\",\n [Proto.OrderPriceField.LADDER_LOW_PRICE]: \"ladder_low_price\",\n [Proto.OrderPriceField.LADDER_HIGH_PRICE]: \"ladder_high_price\",\n [Proto.OrderPriceField.TAKE_PROFIT_TRIGGER_PRICE]: \"take_profit_trigger_price\",\n [Proto.OrderPriceField.TAKE_PROFIT_LIMIT_PRICE]: \"take_profit_limit_price\",\n [Proto.OrderPriceField.STOP_LOSS_TRIGGER_PRICE]: \"stop_loss_trigger_price\",\n [Proto.OrderPriceField.STOP_LOSS_LIMIT_PRICE]: \"stop_loss_limit_price\",\n [Proto.OrderPriceField.TRAILING_STOP_ACTIVATION_PRICE]: \"trailing_stop_activation_price\",\n [Proto.OrderPriceField.TRAILING_STOP_LIMIT_PRICE]: \"trailing_stop_limit_price\",\n } satisfies ProtoToOutput<Proto.OrderPriceField, AssistantOrderPriceField>,\n} as const;\n\nexport const PriceOffsetDirectionCodec = {\n protoToOutput: {\n [Proto.PriceOffsetDirection.OFFSET_DIRECTION_UNSPECIFIED]: \"unspecified\",\n [Proto.PriceOffsetDirection.ABOVE]: \"above\",\n [Proto.PriceOffsetDirection.BELOW]: \"below\",\n } satisfies ProtoToOutput<Proto.PriceOffsetDirection, AssistantPriceOffsetDirection>,\n} as const;\n\nexport const PriceRoundingCodec = {\n protoToOutput: {\n [Proto.PriceRounding.ROUNDING_UNSPECIFIED]: \"unspecified\",\n [Proto.PriceRounding.DOWN]: \"down\",\n [Proto.PriceRounding.UP]: \"up\",\n } satisfies ProtoToOutput<Proto.PriceRounding, AssistantPriceRounding>,\n} as const;\n\nexport const UnfilledSlicePolicyCodec = {\n protoToOutput: {\n [Proto.UnfilledSlicePolicy.UNFILLED_SLICE_UNSPECIFIED]: \"unspecified\",\n [Proto.UnfilledSlicePolicy.CANCEL_BEFORE_NEXT]: \"cancel_before_next\",\n } satisfies ProtoToOutput<Proto.UnfilledSlicePolicy, AssistantUnfilledSlicePolicy>,\n} as const;\n\nexport const TriggerChangeActionCodec = {\n protoToOutput: {\n [Proto.TriggerChangeAction.TRIGGER_CHANGE_UNSPECIFIED]: \"unspecified\",\n [Proto.TriggerChangeAction.MODIFY]: \"modify\",\n [Proto.TriggerChangeAction.PAUSE]: \"pause\",\n [Proto.TriggerChangeAction.RESUME]: \"resume\",\n } satisfies ProtoToOutput<Proto.TriggerChangeAction, AssistantTriggerChangeAction>,\n} as const;\n"],"mappings":";;AAkBA,MAAa,qCAAqC,CAAC,WAAW,QAAQ;;;;;;;;AAwBtE,MAAa,mCAAmC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAeA,MAAa,qCAAqC,CAAC,MAAM;AAIzD,MAAa,wBAAwB,EACjC,cAAc,EACV,MAAA,EACJ,EACJ;AAEA,MAAa,4BAA4B,CAAC,MAAM;AAIhD,MAAa,wBAAwB,EACjC,cAAc,EACV,MAAA,EACJ,EACJ;AAEA,MAAa,sBAAsB;CAC/B,cAAc;EACV,YAAA;EACA,UAAA;EACA,UAAA;EACA,aAAA;EACA,aAAA;EACA,eAAA;EACA,YAAA;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,KAAA;AACvD,EACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EACgD,IAAA;EACvB,IAAA;EACA,IAAA;AACxC,EACJ;AAEA,MAAa,qBAAqB,EAC9B,eAAe;EACiC,IAAA;EAChB,IAAA;EACF,IAAA;AAC9B,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC6C,IAAA;EACR,IAAA;AACpD,EACJ;AAEA,MAAa,2BAA2B,EACpC,eAAe;EAC6C,IAAA;EACpB,IAAA;EACD,IAAA;EACC,IAAA;AACxC,EACJ"}
|
|
@@ -3,7 +3,7 @@ import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
|
3
3
|
import { SdkScales } from "../../shared/decimal-surface.js";
|
|
4
4
|
import { AssistantRunEvent } from "./assistant-events.schemas.js";
|
|
5
5
|
import { AssistantApprovalStatus } from "./assistant.codecs.js";
|
|
6
|
-
import { AssistantKey, AssistantRunIdInput, CompleteAssistantKeysInput, DecideAssistantApprovalInput, DeleteAssistantMemoryInput, ListAssistantConversationsInput, ListAssistantConversationsResult, ListAssistantKeysInput, ListAssistantMemoriesInput, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysResult, SendAssistantMessageInput, SetTelegramApprovalLimitsInput, TelegramApprovalLimits, WatchAssistantRunInput } from "./assistant.schemas.js";
|
|
6
|
+
import { AssistantKey, AssistantModelKey, AssistantRunIdInput, AssistantUsage, CompleteAssistantKeysInput, DecideAssistantApprovalInput, DeleteAssistantMemoryInput, GetAssistantMessageImageInput, ListAssistantConversationsInput, ListAssistantConversationsResult, ListAssistantKeysInput, ListAssistantMemoriesInput, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysResult, SendAssistantMessageInput, SetAssistantModelKeyInput, SetTelegramApprovalLimitsInput, TelegramApprovalLimits, WatchAssistantRunInput } from "./assistant.schemas.js";
|
|
7
7
|
//#region src/services/assistant/assistant.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* The Polyester trading assistant. `sendMessage` starts a run that answers the message;
|
|
@@ -18,7 +18,9 @@ declare class AssistantService {
|
|
|
18
18
|
/**
|
|
19
19
|
* Records the message and starts a run that answers it; returns once the run is recorded.
|
|
20
20
|
* Idempotent per `idempotencyKey`: repeat the request unchanged to resolve an unknown
|
|
21
|
-
* outcome. A conversation runs one run at a time (`RUN_ACTIVE`).
|
|
21
|
+
* outcome. A conversation runs one run at a time (`RUN_ACTIVE`). With
|
|
22
|
+
* `expectedLatestRunId`, a conversation that moved on fails with `CONVERSATION_ADVANCED`,
|
|
23
|
+
* a final answer: do not retry it.
|
|
22
24
|
*/
|
|
23
25
|
sendMessage(input: SendAssistantMessageInput, options?: PolyesterRequestOptions): Promise<{
|
|
24
26
|
runId: string;
|
|
@@ -42,6 +44,11 @@ declare class AssistantService {
|
|
|
42
44
|
* the recorded status.
|
|
43
45
|
*/
|
|
44
46
|
decideApproval(input: DecideAssistantApprovalInput, options?: PolyesterRequestOptions): Promise<AssistantApprovalStatus | "unspecified">;
|
|
47
|
+
/** Returns one image of the caller's messages, from `AssistantMessage.images`. */
|
|
48
|
+
getMessageImage(input: GetAssistantMessageImageInput, options?: PolyesterRequestOptions): Promise<{
|
|
49
|
+
data: Uint8Array;
|
|
50
|
+
mimeType: string;
|
|
51
|
+
}>;
|
|
45
52
|
/** Lists the caller's conversations, most recently updated first. */
|
|
46
53
|
listConversations(input?: ListAssistantConversationsInput, options?: PolyesterRequestOptions): Promise<ListAssistantConversationsResult>;
|
|
47
54
|
/** Lists one conversation's messages, newest first. */
|
|
@@ -71,6 +78,26 @@ declare class AssistantService {
|
|
|
71
78
|
* with `apiKeys.deleteAssistantKeys`.
|
|
72
79
|
*/
|
|
73
80
|
listKeys(input?: ListAssistantKeysInput, options?: PolyesterRequestOptions): Promise<AssistantKey[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Saves the caller's own OpenAI API key, replacing any earlier one, once OpenAI accepts it
|
|
83
|
+
* (else `MODEL_KEY_REJECTED`, `MODEL_KEY_NO_QUOTA` or `MODEL_KEY_MODEL_UNAVAILABLE`, and
|
|
84
|
+
* nothing is saved). Messages sent after it use the key instead of credits; a run whose key
|
|
85
|
+
* OpenAI refuses fails with `model_key_refused`. Only a signed-in session sets it.
|
|
86
|
+
*/
|
|
87
|
+
setModelKey(input: SetAssistantModelKeyInput, options?: PolyesterRequestOptions): Promise<AssistantModelKey>;
|
|
88
|
+
/** Returns the caller's own OpenAI API key's status, or `null` when they have none. */
|
|
89
|
+
getModelKey(options?: PolyesterRequestOptions): Promise<AssistantModelKey | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Deletes the caller's own OpenAI API key; later messages use credits again. Runs already
|
|
92
|
+
* started on it never switch. Deleting when there is no key succeeds.
|
|
93
|
+
*/
|
|
94
|
+
deleteModelKey(options?: PolyesterRequestOptions): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the caller's assistant credits today: the VIP tier's free daily credits, how many
|
|
97
|
+
* are used and left, when they reset, what pays for the next messages, and the next tier's
|
|
98
|
+
* free credits. With none left on `credits`, runs fail with `daily_limit_reached`.
|
|
99
|
+
*/
|
|
100
|
+
getUsage(options?: PolyesterRequestOptions): Promise<AssistantUsage>;
|
|
74
101
|
/**
|
|
75
102
|
* Returns the caller's limits on what they may approve from Telegram, in US dollars of
|
|
76
103
|
* notional value, and the value approved from Telegram in the last 24 hours while a limit
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.d.ts","names":[],"sources":["../../../src/services/assistant/assistant.ts"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"assistant.d.ts","names":[],"sources":["../../../src/services/assistant/assistant.ts"],"mappings":";;;;;;;;;;;;;;cAoEa;;EAIG,YAAA,YAAY,mBAAmB,QAAQ;;;;;;;;EAY7C,YACF,OAAO,2BACP,UAAU,0BACX;IAAU;IAAe;;;;;;;;EAkBrB,SACH,OAAO,wBACP,UAAU,0BACX,eAAe;;;;;EAeZ,UAAU,OAAO,qBAAqB,UAAU,0BAA0B;;;;;;EAU1E,eACF,OAAO,8BACP,UAAU,0BACX,QAAQ;;EAOL,gBACF,OAAO,+BACP,UAAU,0BACX;IAAU,MAAM;IAAY;;;EAUzB,kBACF,QAAO,iCACP,UAAU,0BACX,QAAQ;;EAaL,aACF,OAAO,4BACP,UAAU,0BACX,QAAQ;;;;;EAgBL,aACF,QAAO,4BACP,UAAU,0BACX,QAAQ;;EAaL,aACF,OAAO,4BACP,UAAU,0BACX;;;;;;;EAWG,YACF,OAAO,2BACP,UAAU,0BACX,QAAQ;;;;;EAaL,aACF,OAAO,4BACP,UAAU,0BACX,QAAQ;;;;;;EAcL,SACF,QAAO,wBACP,UAAU,0BACX,QAAQ;;;;;;;EAeL,YACF,OAAO,2BACP,UAAU,0BACX,QAAQ;;EAOL,YAAY,UAAU,0BAA0B,QAAQ;;;;;EASxD,eAAe,UAAU,0BAA0B;;;;;;EASnD,SAAS,UAAU,0BAA0B,QAAQ;;;;;;;EAUrD,0BACF,UAAU,0BACX,QAAQ;IAA2B;;;;;;;EAgBhC,0BACF,OAAO,gCACP,UAAU,0BACX,QAAQ"}
|
|
@@ -6,7 +6,7 @@ import { enumLabel } from "../../shared/proto-enum-codec.js";
|
|
|
6
6
|
import { AssistantService as AssistantService$1 } from "../../gen/ai/v1/assistant_pb.js";
|
|
7
7
|
import { ApprovalStatusCodec } from "./assistant.codecs.js";
|
|
8
8
|
import { formatRunEvent } from "./assistant-events.schemas.js";
|
|
9
|
-
import { AssistantRunIdInputSchema, CompleteAssistantKeysInputSchema, DecideAssistantApprovalInputSchema, DeleteAssistantMemoryInputSchema, ListAssistantConversationsInputSchema, ListAssistantKeysInputSchema, ListAssistantMemoriesInputSchema, ListAssistantMessagesInputSchema, PrepareAssistantKeysInputSchema, SendAssistantMessageInputSchema, SetTelegramApprovalLimitsInputSchema, WatchAssistantRunInputSchema, formatAssistantKey, formatConversation, formatMemory, formatMessage, formatPrepareAssistantKeysResult, formatTelegramApprovalLimits } from "./assistant.schemas.js";
|
|
9
|
+
import { AssistantRunIdInputSchema, CompleteAssistantKeysInputSchema, DecideAssistantApprovalInputSchema, DeleteAssistantMemoryInputSchema, GetAssistantMessageImageInputSchema, ListAssistantConversationsInputSchema, ListAssistantKeysInputSchema, ListAssistantMemoriesInputSchema, ListAssistantMessagesInputSchema, PrepareAssistantKeysInputSchema, SendAssistantMessageInputSchema, SetAssistantModelKeyInputSchema, SetTelegramApprovalLimitsInputSchema, WatchAssistantRunInputSchema, formatAssistantKey, formatAssistantUsage, formatConversation, formatMemory, formatMessage, formatModelKey, formatPrepareAssistantKeysResult, formatTelegramApprovalLimits } from "./assistant.schemas.js";
|
|
10
10
|
import { createClient } from "@connectrpc/connect";
|
|
11
11
|
//#region src/services/assistant/assistant.ts
|
|
12
12
|
/**
|
|
@@ -26,7 +26,9 @@ var AssistantService = class {
|
|
|
26
26
|
/**
|
|
27
27
|
* Records the message and starts a run that answers it; returns once the run is recorded.
|
|
28
28
|
* Idempotent per `idempotencyKey`: repeat the request unchanged to resolve an unknown
|
|
29
|
-
* outcome. A conversation runs one run at a time (`RUN_ACTIVE`).
|
|
29
|
+
* outcome. A conversation runs one run at a time (`RUN_ACTIVE`). With
|
|
30
|
+
* `expectedLatestRunId`, a conversation that moved on fails with `CONVERSATION_ADVANCED`,
|
|
31
|
+
* a final answer: do not retry it.
|
|
30
32
|
*/
|
|
31
33
|
async sendMessage(input, options) {
|
|
32
34
|
const request = parse(SendAssistantMessageInputSchema, input);
|
|
@@ -65,6 +67,15 @@ var AssistantService = class {
|
|
|
65
67
|
const response = await this.#client.decideApproval(request, toConnectCallOptions(options));
|
|
66
68
|
return enumLabel(ApprovalStatusCodec.protoToOutput, response.status);
|
|
67
69
|
}
|
|
70
|
+
/** Returns one image of the caller's messages, from `AssistantMessage.images`. */
|
|
71
|
+
async getMessageImage(input, options) {
|
|
72
|
+
const request = parse(GetAssistantMessageImageInputSchema, input);
|
|
73
|
+
const { data, mimeType } = await this.#client.getMessageImage(request, toConnectCallOptions(options));
|
|
74
|
+
return {
|
|
75
|
+
data,
|
|
76
|
+
mimeType
|
|
77
|
+
};
|
|
78
|
+
}
|
|
68
79
|
/** Lists the caller's conversations, most recently updated first. */
|
|
69
80
|
async listConversations(input = {}, options) {
|
|
70
81
|
const request = parse(ListAssistantConversationsInputSchema, input);
|
|
@@ -129,6 +140,37 @@ var AssistantService = class {
|
|
|
129
140
|
return (await this.#client.listAssistantKeys(removeUndefined(request), toConnectCallOptions(options))).keys.map(formatAssistantKey);
|
|
130
141
|
}
|
|
131
142
|
/**
|
|
143
|
+
* Saves the caller's own OpenAI API key, replacing any earlier one, once OpenAI accepts it
|
|
144
|
+
* (else `MODEL_KEY_REJECTED`, `MODEL_KEY_NO_QUOTA` or `MODEL_KEY_MODEL_UNAVAILABLE`, and
|
|
145
|
+
* nothing is saved). Messages sent after it use the key instead of credits; a run whose key
|
|
146
|
+
* OpenAI refuses fails with `model_key_refused`. Only a signed-in session sets it.
|
|
147
|
+
*/
|
|
148
|
+
async setModelKey(input, options) {
|
|
149
|
+
const request = parse(SetAssistantModelKeyInputSchema, input);
|
|
150
|
+
const response = await this.#client.setModelKey(request, toConnectCallOptions(options));
|
|
151
|
+
return formatModelKey(response.key);
|
|
152
|
+
}
|
|
153
|
+
/** Returns the caller's own OpenAI API key's status, or `null` when they have none. */
|
|
154
|
+
async getModelKey(options) {
|
|
155
|
+
const response = await this.#client.getModelKey({}, toConnectCallOptions(options));
|
|
156
|
+
return response.key ? formatModelKey(response.key) : null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deletes the caller's own OpenAI API key; later messages use credits again. Runs already
|
|
160
|
+
* started on it never switch. Deleting when there is no key succeeds.
|
|
161
|
+
*/
|
|
162
|
+
async deleteModelKey(options) {
|
|
163
|
+
await this.#client.deleteModelKey({}, toConnectCallOptions(options));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns the caller's assistant credits today: the VIP tier's free daily credits, how many
|
|
167
|
+
* are used and left, when they reset, what pays for the next messages, and the next tier's
|
|
168
|
+
* free credits. With none left on `credits`, runs fail with `daily_limit_reached`.
|
|
169
|
+
*/
|
|
170
|
+
async getUsage(options) {
|
|
171
|
+
return formatAssistantUsage(await this.#client.getUsage({}, toConnectCallOptions(options)));
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
132
174
|
* Returns the caller's limits on what they may approve from Telegram, in US dollars of
|
|
133
175
|
* notional value, and the value approved from Telegram in the last 24 hours while a limit
|
|
134
176
|
* was set. Limits apply to placing, swapping, modifying and resuming; canceling, pausing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.js","names":["#client","Proto.AssistantService","#scales"],"sources":["../../../src/services/assistant/assistant.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/ai/v1/assistant_pb.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { formatRunEvent, type AssistantRunEvent } from \"./assistant-events.schemas.js\";\nimport { ApprovalStatusCodec, type AssistantApprovalStatus } from \"./assistant.codecs.js\";\nimport {\n AssistantRunIdInputSchema,\n CompleteAssistantKeysInputSchema,\n DecideAssistantApprovalInputSchema,\n DeleteAssistantMemoryInputSchema,\n formatAssistantKey,\n formatConversation,\n formatMemory,\n formatMessage,\n formatPrepareAssistantKeysResult,\n formatTelegramApprovalLimits,\n ListAssistantConversationsInputSchema,\n ListAssistantMemoriesInputSchema,\n ListAssistantMessagesInputSchema,\n PrepareAssistantKeysInputSchema,\n SendAssistantMessageInputSchema,\n SetTelegramApprovalLimitsInputSchema,\n WatchAssistantRunInputSchema,\n type AssistantKey,\n type AssistantRunIdInput,\n type CompleteAssistantKeysInput,\n ListAssistantKeysInputSchema,\n type ListAssistantKeysInput,\n type DecideAssistantApprovalInput,\n type DeleteAssistantMemoryInput,\n type ListAssistantConversationsInput,\n type ListAssistantConversationsResult,\n type ListAssistantMemoriesInput,\n type ListAssistantMemoriesResult,\n type ListAssistantMessagesInput,\n type ListAssistantMessagesResult,\n type PrepareAssistantKeysInput,\n type PrepareAssistantKeysResult,\n type SendAssistantMessageInput,\n type SetTelegramApprovalLimitsInput,\n type TelegramApprovalLimits,\n type WatchAssistantRunInput,\n} from \"./assistant.schemas.js\";\n\n/**\n * The Polyester trading assistant. `sendMessage` starts a run that answers the message;\n * follow it with `watchRun`. A run continues on the server when nobody watches it. Actions that\n * change the account wait for `decideApproval`. Needs a session login; every conversation, run,\n * approval and memory belongs to the signed-in user. Errors carry\n * `detail: { service: \"assistant\", code }`.\n */\nexport class AssistantService {\n #client: Client<typeof Proto.AssistantService>;\n #scales: SdkScales;\n\n constructor(transports: AuthApiTransports, scales: SdkScales) {\n this.#client = createClient(Proto.AssistantService, transports.authApi);\n this.#scales = scales;\n }\n\n /**\n * Records the message and starts a run that answers it; returns once the run is recorded.\n * Idempotent per `idempotencyKey`: repeat the request unchanged to resolve an unknown\n * outcome. A conversation runs one run at a time (`RUN_ACTIVE`).\n */\n async sendMessage(\n input: SendAssistantMessageInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ runId: string; conversationId: string }> {\n const request = parse(SendAssistantMessageInputSchema, input);\n const response = await this.#client.sendMessage(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n runId: formatId(response.runId),\n conversationId: formatId(response.conversationId),\n };\n }\n\n /**\n * Streams a run's events in `seq` order: the recorded events after `afterSeq`, then new ones\n * as they are recorded. Ends after `run_completed` or `run_failed`; watching an ended run\n * replays it. The server may end the stream early: call again with the last `seq` received\n * as `afterSeq` to continue without gaps or repeats. Abort with `options.signal`.\n */\n async *watchRun(\n input: WatchAssistantRunInput,\n options?: PolyesterRequestOptions,\n ): AsyncGenerator<AssistantRunEvent, void, undefined> {\n const request = parse(WatchAssistantRunInputSchema, input);\n await this.#scales.ready();\n for await (const response of this.#client.watchRun(\n request,\n toConnectCallOptions(options),\n )) {\n if (response.event) yield formatRunEvent(response.event, this.#scales);\n }\n }\n\n /**\n * Asks an active run to stop; it then ends with `run_failed` category `canceled`.\n * Canceling an ended run succeeds and changes nothing.\n */\n async cancelRun(input: AssistantRunIdInput, options?: PolyesterRequestOptions): Promise<void> {\n const request = parse(AssistantRunIdInputSchema, input);\n await this.#client.cancelRun(request, toConnectCallOptions(options));\n }\n\n /**\n * Approves or rejects a pending approval from an `approval_requested` event. An approved\n * action runs exactly as its summary says, at most once. Repeating the same decision returns\n * the recorded status.\n */\n async decideApproval(\n input: DecideAssistantApprovalInput,\n options?: PolyesterRequestOptions,\n ): Promise<AssistantApprovalStatus | \"unspecified\"> {\n const request = parse(DecideAssistantApprovalInputSchema, input);\n const response = await this.#client.decideApproval(request, toConnectCallOptions(options));\n return enumLabel(ApprovalStatusCodec.protoToOutput, response.status);\n }\n\n /** Lists the caller's conversations, most recently updated first. */\n async listConversations(\n input: ListAssistantConversationsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListAssistantConversationsResult> {\n const request = parse(ListAssistantConversationsInputSchema, input);\n const response = await this.#client.listConversations(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n conversations: response.conversations.map(formatConversation),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Lists one conversation's messages, newest first. */\n async listMessages(\n input: ListAssistantMessagesInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListAssistantMessagesResult> {\n const request = parse(ListAssistantMessagesInputSchema, input);\n const response = await this.#client.listMessages(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n messages: response.messages.map(formatMessage),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /**\n * Lists what the assistant remembers about the caller, newest first. A `profile` memory\n * applies to every answer; the others are used when relevant.\n */\n async listMemories(\n input: ListAssistantMemoriesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListAssistantMemoriesResult> {\n const request = parse(ListAssistantMemoriesInputSchema, input);\n const response = await this.#client.listMemories(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n memories: response.memories.map(formatMemory),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Makes the assistant forget one memory. Deleting a deleted memory succeeds. */\n async deleteMemory(\n input: DeleteAssistantMemoryInput,\n options?: PolyesterRequestOptions,\n ): Promise<void> {\n const request = parse(DeleteAssistantMemoryInputSchema, input);\n await this.#client.deleteMemory(request, toConnectCallOptions(options));\n }\n\n /**\n * Step 1 of giving the assistant keys: the assistant generates one Ed25519 key pair per\n * account and returns the public keys with their registration proofs. Register them with\n * `apiKeys.setAssistantKeys` (with a fresh `stepUpToken`) before `expiresAt`, then call\n * `completeKeys`. The step-up token goes to `setAssistantKeys` only, never to the assistant.\n */\n async prepareKeys(\n input: PrepareAssistantKeysInput,\n options?: PolyesterRequestOptions,\n ): Promise<PrepareAssistantKeysResult> {\n const request = parse(PrepareAssistantKeysInputSchema, input);\n const response = await this.#client.prepareAssistantKeys(\n { accounts: request.accounts.map((account) => removeUndefined(account)) },\n toConnectCallOptions(options),\n );\n return formatPrepareAssistantKeysResult(response);\n }\n\n /**\n * Finishes a key setup once `apiKeys.setAssistantKeys` registered its keys; returns the keys\n * the assistant now holds. Completing a completed setup returns the keys again.\n */\n async completeKeys(\n input: CompleteAssistantKeysInput,\n options?: PolyesterRequestOptions,\n ): Promise<AssistantKey[]> {\n const request = parse(CompleteAssistantKeysInputSchema, input);\n const response = await this.#client.completeAssistantKeys(\n request,\n toConnectCallOptions(options),\n );\n return response.keys.map(formatAssistantKey);\n }\n\n /**\n * Lists the keys the assistant holds, at most one per account. An account without one has\n * no account tools. Pass `view: \"full\"` for each key's account name as `label`. Revoke them\n * with `apiKeys.deleteAssistantKeys`.\n */\n async listKeys(\n input: ListAssistantKeysInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<AssistantKey[]> {\n const request = parse(ListAssistantKeysInputSchema, input);\n const response = await this.#client.listAssistantKeys(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return response.keys.map(formatAssistantKey);\n }\n\n /**\n * Returns the caller's limits on what they may approve from Telegram, in US dollars of\n * notional value, and the value approved from Telegram in the last 24 hours while a limit\n * was set. Limits apply to placing, swapping, modifying and resuming; canceling, pausing\n * and rejecting are never limited.\n */\n async getTelegramApprovalLimits(\n options?: PolyesterRequestOptions,\n ): Promise<TelegramApprovalLimits & { approvedLast24hUsd: string }> {\n const response = await this.#client.getTelegramApprovalLimits(\n {},\n toConnectCallOptions(options),\n );\n return {\n ...formatTelegramApprovalLimits(response.limits),\n approvedLast24hUsd: response.approvedLast24hUsd,\n };\n }\n\n /**\n * Replaces both Telegram approval limits: a limit left out is turned off. Only a signed-in\n * session sets them; they apply to the next approval from Telegram. Returns the limits as\n * recorded.\n */\n async setTelegramApprovalLimits(\n input: SetTelegramApprovalLimitsInput,\n options?: PolyesterRequestOptions,\n ): Promise<TelegramApprovalLimits> {\n const limits = parse(SetTelegramApprovalLimitsInputSchema, input);\n const response = await this.#client.setTelegramApprovalLimits(\n { limits: removeUndefined(limits) },\n toConnectCallOptions(options),\n );\n return formatTelegramApprovalLimits(response.limits);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4DA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CAEA,YAAY,YAA+B,QAAmB;EAC1D,KAAKA,UAAU,aAAaC,oBAAwB,WAAW,OAAO;EACtE,KAAKC,UAAU;CACnB;;;;;;CAOA,MAAM,YACF,OACA,SACkD;EAClD,MAAM,UAAU,MAAM,iCAAiC,KAAK;EAC5D,MAAM,WAAW,MAAM,KAAKF,QAAQ,YAChC,gBAAgB,OAA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AAW,MAAM,KAAKA,QAAQ,0BAChC,EAAE,QAAQ,gBAAgB,MAAM,EAAE,GAClC,qBAAqB,OAAO,CAChC;EACA,OAAO,6BAA6B,SAAS,MAAM;CACvD;AACJ"}
|
|
1
|
+
{"version":3,"file":"assistant.js","names":["#client","Proto.AssistantService","#scales"],"sources":["../../../src/services/assistant/assistant.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/ai/v1/assistant_pb.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { formatRunEvent, type AssistantRunEvent } from \"./assistant-events.schemas.js\";\nimport { ApprovalStatusCodec, type AssistantApprovalStatus } from \"./assistant.codecs.js\";\nimport {\n AssistantRunIdInputSchema,\n CompleteAssistantKeysInputSchema,\n DecideAssistantApprovalInputSchema,\n DeleteAssistantMemoryInputSchema,\n formatAssistantKey,\n formatAssistantUsage,\n formatConversation,\n formatMemory,\n formatMessage,\n formatModelKey,\n formatPrepareAssistantKeysResult,\n formatTelegramApprovalLimits,\n GetAssistantMessageImageInputSchema,\n ListAssistantConversationsInputSchema,\n ListAssistantMemoriesInputSchema,\n ListAssistantMessagesInputSchema,\n PrepareAssistantKeysInputSchema,\n SendAssistantMessageInputSchema,\n SetAssistantModelKeyInputSchema,\n SetTelegramApprovalLimitsInputSchema,\n WatchAssistantRunInputSchema,\n type AssistantKey,\n type AssistantModelKey,\n type AssistantUsage,\n type GetAssistantMessageImageInput,\n type AssistantRunIdInput,\n type CompleteAssistantKeysInput,\n ListAssistantKeysInputSchema,\n type ListAssistantKeysInput,\n type DecideAssistantApprovalInput,\n type DeleteAssistantMemoryInput,\n type ListAssistantConversationsInput,\n type ListAssistantConversationsResult,\n type ListAssistantMemoriesInput,\n type ListAssistantMemoriesResult,\n type ListAssistantMessagesInput,\n type ListAssistantMessagesResult,\n type PrepareAssistantKeysInput,\n type PrepareAssistantKeysResult,\n type SendAssistantMessageInput,\n type SetAssistantModelKeyInput,\n type SetTelegramApprovalLimitsInput,\n type TelegramApprovalLimits,\n type WatchAssistantRunInput,\n} from \"./assistant.schemas.js\";\n\n/**\n * The Polyester trading assistant. `sendMessage` starts a run that answers the message;\n * follow it with `watchRun`. A run continues on the server when nobody watches it. Actions that\n * change the account wait for `decideApproval`. Needs a session login; every conversation, run,\n * approval and memory belongs to the signed-in user. Errors carry\n * `detail: { service: \"assistant\", code }`.\n */\nexport class AssistantService {\n #client: Client<typeof Proto.AssistantService>;\n #scales: SdkScales;\n\n constructor(transports: AuthApiTransports, scales: SdkScales) {\n this.#client = createClient(Proto.AssistantService, transports.authApi);\n this.#scales = scales;\n }\n\n /**\n * Records the message and starts a run that answers it; returns once the run is recorded.\n * Idempotent per `idempotencyKey`: repeat the request unchanged to resolve an unknown\n * outcome. A conversation runs one run at a time (`RUN_ACTIVE`). With\n * `expectedLatestRunId`, a conversation that moved on fails with `CONVERSATION_ADVANCED`,\n * a final answer: do not retry it.\n */\n async sendMessage(\n input: SendAssistantMessageInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ runId: string; conversationId: string }> {\n const request = parse(SendAssistantMessageInputSchema, input);\n const response = await this.#client.sendMessage(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n runId: formatId(response.runId),\n conversationId: formatId(response.conversationId),\n };\n }\n\n /**\n * Streams a run's events in `seq` order: the recorded events after `afterSeq`, then new ones\n * as they are recorded. Ends after `run_completed` or `run_failed`; watching an ended run\n * replays it. The server may end the stream early: call again with the last `seq` received\n * as `afterSeq` to continue without gaps or repeats. Abort with `options.signal`.\n */\n async *watchRun(\n input: WatchAssistantRunInput,\n options?: PolyesterRequestOptions,\n ): AsyncGenerator<AssistantRunEvent, void, undefined> {\n const request = parse(WatchAssistantRunInputSchema, input);\n await this.#scales.ready();\n for await (const response of this.#client.watchRun(\n request,\n toConnectCallOptions(options),\n )) {\n if (response.event) yield formatRunEvent(response.event, this.#scales);\n }\n }\n\n /**\n * Asks an active run to stop; it then ends with `run_failed` category `canceled`.\n * Canceling an ended run succeeds and changes nothing.\n */\n async cancelRun(input: AssistantRunIdInput, options?: PolyesterRequestOptions): Promise<void> {\n const request = parse(AssistantRunIdInputSchema, input);\n await this.#client.cancelRun(request, toConnectCallOptions(options));\n }\n\n /**\n * Approves or rejects a pending approval from an `approval_requested` event. An approved\n * action runs exactly as its summary says, at most once. Repeating the same decision returns\n * the recorded status.\n */\n async decideApproval(\n input: DecideAssistantApprovalInput,\n options?: PolyesterRequestOptions,\n ): Promise<AssistantApprovalStatus | \"unspecified\"> {\n const request = parse(DecideAssistantApprovalInputSchema, input);\n const response = await this.#client.decideApproval(request, toConnectCallOptions(options));\n return enumLabel(ApprovalStatusCodec.protoToOutput, response.status);\n }\n\n /** Returns one image of the caller's messages, from `AssistantMessage.images`. */\n async getMessageImage(\n input: GetAssistantMessageImageInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ data: Uint8Array; mimeType: string }> {\n const request = parse(GetAssistantMessageImageInputSchema, input);\n const { data, mimeType } = await this.#client.getMessageImage(\n request,\n toConnectCallOptions(options),\n );\n return { data, mimeType };\n }\n\n /** Lists the caller's conversations, most recently updated first. */\n async listConversations(\n input: ListAssistantConversationsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListAssistantConversationsResult> {\n const request = parse(ListAssistantConversationsInputSchema, input);\n const response = await this.#client.listConversations(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n conversations: response.conversations.map(formatConversation),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Lists one conversation's messages, newest first. */\n async listMessages(\n input: ListAssistantMessagesInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListAssistantMessagesResult> {\n const request = parse(ListAssistantMessagesInputSchema, input);\n const response = await this.#client.listMessages(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n messages: response.messages.map(formatMessage),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /**\n * Lists what the assistant remembers about the caller, newest first. A `profile` memory\n * applies to every answer; the others are used when relevant.\n */\n async listMemories(\n input: ListAssistantMemoriesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListAssistantMemoriesResult> {\n const request = parse(ListAssistantMemoriesInputSchema, input);\n const response = await this.#client.listMemories(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n memories: response.memories.map(formatMemory),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Makes the assistant forget one memory. Deleting a deleted memory succeeds. */\n async deleteMemory(\n input: DeleteAssistantMemoryInput,\n options?: PolyesterRequestOptions,\n ): Promise<void> {\n const request = parse(DeleteAssistantMemoryInputSchema, input);\n await this.#client.deleteMemory(request, toConnectCallOptions(options));\n }\n\n /**\n * Step 1 of giving the assistant keys: the assistant generates one Ed25519 key pair per\n * account and returns the public keys with their registration proofs. Register them with\n * `apiKeys.setAssistantKeys` (with a fresh `stepUpToken`) before `expiresAt`, then call\n * `completeKeys`. The step-up token goes to `setAssistantKeys` only, never to the assistant.\n */\n async prepareKeys(\n input: PrepareAssistantKeysInput,\n options?: PolyesterRequestOptions,\n ): Promise<PrepareAssistantKeysResult> {\n const request = parse(PrepareAssistantKeysInputSchema, input);\n const response = await this.#client.prepareAssistantKeys(\n { accounts: request.accounts.map((account) => removeUndefined(account)) },\n toConnectCallOptions(options),\n );\n return formatPrepareAssistantKeysResult(response);\n }\n\n /**\n * Finishes a key setup once `apiKeys.setAssistantKeys` registered its keys; returns the keys\n * the assistant now holds. Completing a completed setup returns the keys again.\n */\n async completeKeys(\n input: CompleteAssistantKeysInput,\n options?: PolyesterRequestOptions,\n ): Promise<AssistantKey[]> {\n const request = parse(CompleteAssistantKeysInputSchema, input);\n const response = await this.#client.completeAssistantKeys(\n request,\n toConnectCallOptions(options),\n );\n return response.keys.map(formatAssistantKey);\n }\n\n /**\n * Lists the keys the assistant holds, at most one per account. An account without one has\n * no account tools. Pass `view: \"full\"` for each key's account name as `label`. Revoke them\n * with `apiKeys.deleteAssistantKeys`.\n */\n async listKeys(\n input: ListAssistantKeysInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<AssistantKey[]> {\n const request = parse(ListAssistantKeysInputSchema, input);\n const response = await this.#client.listAssistantKeys(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return response.keys.map(formatAssistantKey);\n }\n\n /**\n * Saves the caller's own OpenAI API key, replacing any earlier one, once OpenAI accepts it\n * (else `MODEL_KEY_REJECTED`, `MODEL_KEY_NO_QUOTA` or `MODEL_KEY_MODEL_UNAVAILABLE`, and\n * nothing is saved). Messages sent after it use the key instead of credits; a run whose key\n * OpenAI refuses fails with `model_key_refused`. Only a signed-in session sets it.\n */\n async setModelKey(\n input: SetAssistantModelKeyInput,\n options?: PolyesterRequestOptions,\n ): Promise<AssistantModelKey> {\n const request = parse(SetAssistantModelKeyInputSchema, input);\n const response = await this.#client.setModelKey(request, toConnectCallOptions(options));\n return formatModelKey(response.key);\n }\n\n /** Returns the caller's own OpenAI API key's status, or `null` when they have none. */\n async getModelKey(options?: PolyesterRequestOptions): Promise<AssistantModelKey | null> {\n const response = await this.#client.getModelKey({}, toConnectCallOptions(options));\n return response.key ? formatModelKey(response.key) : null;\n }\n\n /**\n * Deletes the caller's own OpenAI API key; later messages use credits again. Runs already\n * started on it never switch. Deleting when there is no key succeeds.\n */\n async deleteModelKey(options?: PolyesterRequestOptions): Promise<void> {\n await this.#client.deleteModelKey({}, toConnectCallOptions(options));\n }\n\n /**\n * Returns the caller's assistant credits today: the VIP tier's free daily credits, how many\n * are used and left, when they reset, what pays for the next messages, and the next tier's\n * free credits. With none left on `credits`, runs fail with `daily_limit_reached`.\n */\n async getUsage(options?: PolyesterRequestOptions): Promise<AssistantUsage> {\n return formatAssistantUsage(await this.#client.getUsage({}, toConnectCallOptions(options)));\n }\n\n /**\n * Returns the caller's limits on what they may approve from Telegram, in US dollars of\n * notional value, and the value approved from Telegram in the last 24 hours while a limit\n * was set. Limits apply to placing, swapping, modifying and resuming; canceling, pausing\n * and rejecting are never limited.\n */\n async getTelegramApprovalLimits(\n options?: PolyesterRequestOptions,\n ): Promise<TelegramApprovalLimits & { approvedLast24hUsd: string }> {\n const response = await this.#client.getTelegramApprovalLimits(\n {},\n toConnectCallOptions(options),\n );\n return {\n ...formatTelegramApprovalLimits(response.limits),\n approvedLast24hUsd: response.approvedLast24hUsd,\n };\n }\n\n /**\n * Replaces both Telegram approval limits: a limit left out is turned off. Only a signed-in\n * session sets them; they apply to the next approval from Telegram. Returns the limits as\n * recorded.\n */\n async setTelegramApprovalLimits(\n input: SetTelegramApprovalLimitsInput,\n options?: PolyesterRequestOptions,\n ): Promise<TelegramApprovalLimits> {\n const limits = parse(SetTelegramApprovalLimitsInputSchema, input);\n const response = await this.#client.setTelegramApprovalLimits(\n { limits: removeUndefined(limits) },\n toConnectCallOptions(options),\n );\n return formatTelegramApprovalLimits(response.limits);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoEA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CAEA,YAAY,YAA+B,QAAmB;EAC1D,KAAKA,UAAU,aAAaC,oBAAwB,WAAW,OAAO;EACtE,KAAKC,UAAU;CACnB;;;;;;;;CASA,MAAM,YACF,OACA,SACkD;EAClD,MAAM,UAAU,MAAM,iCAAiC,KAAK;EAC5D,MAAM,WAAW,MAAM,KAAKF,QAAQ,YAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,OAAO,SAAS,SAAS,KAAK;GAC9B,gBAAgB,SAAS,SAAS,cAAc;EACpD;CACJ;;;;;;;CAQA,OAAO,SACH,OACA,SACkD;EAClD,MAAM,UAAU,MAAM,8BAA8B,KAAK;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AAqB,OAAO,CAAC;EACjF,OAAO,SAAS,MAAM,eAAe,SAAS,GAAG,IAAI;CACzD;;;;;CAMA,MAAM,eAAe,SAAkD;EACnE,MAAM,KAAKA,QAAQ,eAAe,CAAC,GAAG,qBAAqB,OAAO,CAAC;CACvE;;;;;;CAOA,MAAM,SAAS,SAA4D;EACvE,OAAO,qBAAqB,MAAM,KAAKA,QAAQ,SAAS,CAAC,GAAG,qBAAqB,OAAO,CAAC,CAAC;CAC9F;;;;;;;CAQA,MAAM,0BACF,SACgE;EAChE,MAAM,WAAW,MAAM,KAAKA,QAAQ,0BAChC,CAAC,GACD,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,GAAG,6BAA6B,SAAS,MAAM;GAC/C,oBAAoB,SAAS;EACjC;CACJ;;;;;;CAOA,MAAM,0BACF,OACA,SAC+B;EAC/B,MAAM,SAAS,MAAM,sCAAsC,KAAK;EAChE,MAAM,WAAW,MAAM,KAAKA,QAAQ,0BAChC,EAAE,QAAQ,gBAAgB,MAAM,EAAE,GAClC,qBAAqB,OAAO,CAChC;EACA,OAAO,6BAA6B,SAAS,MAAM;CACvD;AACJ"}
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import { AccountSelection, ApprovalDecision, AssistantKey as AssistantKey$1, AssistantKeyView, Conversation, DisplaySetting, Memory, Message, PrepareAssistantKeysResponse, PreparedAssistantKey as PreparedAssistantKey$1 } from "../../gen/ai/v1/assistant_pb.js";
|
|
1
|
+
import { AccountSelection, ApprovalDecision, AssistantKey as AssistantKey$1, AssistantKeyView, Conversation, DisplaySetting, GetUsageResponse, Memory, Message, MessageImage, ModelKey, PrepareAssistantKeysResponse, PreparedAssistantKey as PreparedAssistantKey$1 } from "../../gen/ai/v1/assistant_pb.js";
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
//#region src/services/assistant/assistant.schemas.d.ts
|
|
4
4
|
declare const SendAssistantMessageInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
5
5
|
/** Conversation to continue; omit to start a new one. */
|
|
6
6
|
readonly conversationId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, undefined>;
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Message text, plain text or Markdown, at most 16000 characters. Required unless
|
|
9
|
+
* `images` are attached; with images, it is the question about them.
|
|
10
|
+
*/
|
|
11
|
+
readonly text: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 16000, undefined>]>, undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Images the message shows the assistant, such as a screenshot, in the order the user
|
|
14
|
+
* attached them: PNG, JPEG or WebP, at most 4, each at most 10 MiB. Covered by
|
|
15
|
+
* `idempotencyKey`.
|
|
16
|
+
*/
|
|
17
|
+
readonly images: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
18
|
+
readonly data: v.InstanceSchema<Uint8ArrayConstructor, undefined>;
|
|
19
|
+
/** `"image/png"`, `"image/jpeg"` or `"image/webp"`, matching `data`. */
|
|
20
|
+
readonly mimeType: v.StringSchema<undefined>;
|
|
21
|
+
}, undefined>, undefined>, undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Send only while this run is still the conversation's latest, e.g. the run of the
|
|
24
|
+
* answer a follow-up button sits under; otherwise nothing is recorded and the call fails
|
|
25
|
+
* with `CONVERSATION_ADVANCED`. Needs `conversationId`. Covered by `idempotencyKey`.
|
|
26
|
+
*/
|
|
27
|
+
readonly expectedLatestRunId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, undefined>;
|
|
9
28
|
/** Client-chosen key, unique per caller. Repeat the request unchanged to resolve an unknown outcome. */
|
|
10
29
|
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
11
30
|
/**
|
|
@@ -56,7 +75,12 @@ declare const SendAssistantMessageInputSchema: v.SchemaWithPipe<readonly [v.Stri
|
|
|
56
75
|
readonly displaySettings: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["appearance", "language", "currency", "date_format", "time_format", "number_format", "week_start", "sounds"], undefined>, undefined>, v.CheckAction<("appearance" | "language" | "currency" | "date_format" | "time_format" | "number_format" | "week_start" | "sounds")[], "Display settings must be distinct.">, v.TransformAction<("appearance" | "language" | "currency" | "date_format" | "time_format" | "number_format" | "week_start" | "sounds")[], (DisplaySetting.APPEARANCE | DisplaySetting.LANGUAGE | DisplaySetting.CURRENCY | DisplaySetting.DATE_FORMAT | DisplaySetting.TIME_FORMAT | DisplaySetting.NUMBER_FORMAT | DisplaySetting.WEEK_START | DisplaySetting.SOUNDS)[]>]>, undefined>;
|
|
57
76
|
}, undefined>, v.CheckAction<{
|
|
58
77
|
conversationId?: bigint | undefined;
|
|
59
|
-
text
|
|
78
|
+
text?: string | undefined;
|
|
79
|
+
images?: {
|
|
80
|
+
data: Uint8Array<ArrayBuffer>;
|
|
81
|
+
mimeType: string;
|
|
82
|
+
}[] | undefined;
|
|
83
|
+
expectedLatestRunId?: bigint | undefined;
|
|
60
84
|
idempotencyKey: string;
|
|
61
85
|
subaccountId?: bigint | undefined;
|
|
62
86
|
accountSelection?: AccountSelection.NONE | undefined;
|
|
@@ -71,7 +95,29 @@ declare const SendAssistantMessageInputSchema: v.SchemaWithPipe<readonly [v.Stri
|
|
|
71
95
|
title: string;
|
|
72
96
|
} | undefined;
|
|
73
97
|
displaySettings?: (DisplaySetting.APPEARANCE | DisplaySetting.LANGUAGE | DisplaySetting.CURRENCY | DisplaySetting.DATE_FORMAT | DisplaySetting.TIME_FORMAT | DisplaySetting.NUMBER_FORMAT | DisplaySetting.WEEK_START | DisplaySetting.SOUNDS)[] | undefined;
|
|
74
|
-
}, "Omit subaccountId when accountSelection is \"none\"."
|
|
98
|
+
}, "Omit subaccountId when accountSelection is \"none\".">, v.CheckAction<{
|
|
99
|
+
conversationId?: bigint | undefined;
|
|
100
|
+
text?: string | undefined;
|
|
101
|
+
images?: {
|
|
102
|
+
data: Uint8Array<ArrayBuffer>;
|
|
103
|
+
mimeType: string;
|
|
104
|
+
}[] | undefined;
|
|
105
|
+
expectedLatestRunId?: bigint | undefined;
|
|
106
|
+
idempotencyKey: string;
|
|
107
|
+
subaccountId?: bigint | undefined;
|
|
108
|
+
accountSelection?: AccountSelection.NONE | undefined;
|
|
109
|
+
destinations?: {
|
|
110
|
+
id: string;
|
|
111
|
+
title: string;
|
|
112
|
+
description: string;
|
|
113
|
+
}[] | undefined;
|
|
114
|
+
page?: {
|
|
115
|
+
destinationId?: string | undefined;
|
|
116
|
+
route: string;
|
|
117
|
+
title: string;
|
|
118
|
+
} | undefined;
|
|
119
|
+
displaySettings?: (DisplaySetting.APPEARANCE | DisplaySetting.LANGUAGE | DisplaySetting.CURRENCY | DisplaySetting.DATE_FORMAT | DisplaySetting.TIME_FORMAT | DisplaySetting.NUMBER_FORMAT | DisplaySetting.WEEK_START | DisplaySetting.SOUNDS)[] | undefined;
|
|
120
|
+
}, "A message needs text, images or both.">]>;
|
|
75
121
|
type SendAssistantMessageInput = v.InferInput<typeof SendAssistantMessageInputSchema>;
|
|
76
122
|
declare const AssistantRunIdInputSchema: v.StrictObjectSchema<{
|
|
77
123
|
readonly runId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
@@ -139,6 +185,15 @@ declare const PrepareAssistantKeysInputSchema: v.SchemaWithPipe<readonly [v.Stri
|
|
|
139
185
|
}[];
|
|
140
186
|
}, "Each account may be named only once.">]>;
|
|
141
187
|
type PrepareAssistantKeysInput = v.InferInput<typeof PrepareAssistantKeysInputSchema>;
|
|
188
|
+
declare const GetAssistantMessageImageInputSchema: v.StrictObjectSchema<{
|
|
189
|
+
readonly imageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
190
|
+
}, undefined>;
|
|
191
|
+
type GetAssistantMessageImageInput = v.InferInput<typeof GetAssistantMessageImageInputSchema>;
|
|
192
|
+
declare const SetAssistantModelKeyInputSchema: v.StrictObjectSchema<{
|
|
193
|
+
/** An OpenAI secret API key (`sk-...`). Never logged or returned. */
|
|
194
|
+
readonly apiKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
195
|
+
}, undefined>;
|
|
196
|
+
type SetAssistantModelKeyInput = v.InferInput<typeof SetAssistantModelKeyInputSchema>;
|
|
142
197
|
declare const CompleteAssistantKeysInputSchema: v.StrictObjectSchema<{
|
|
143
198
|
readonly setupId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
144
199
|
}, undefined>;
|
|
@@ -159,7 +214,27 @@ declare function formatMessage(m: Message): {
|
|
|
159
214
|
createdAt: number | undefined;
|
|
160
215
|
/** Replay this run with `watchRun` from `afterSeq: 0` to show its tool activity and views. */
|
|
161
216
|
runId: string;
|
|
217
|
+
/** A user message's images, in the order sent; read each with `getMessageImage`. */
|
|
218
|
+
images: {
|
|
219
|
+
imageId: string;
|
|
220
|
+
/** `"image/png"`, `"image/jpeg"` or `"image/webp"`. */
|
|
221
|
+
mimeType: string;
|
|
222
|
+
/** Pixels; an image over 2000 pixels on a side is stored scaled down to fit. */
|
|
223
|
+
width: number;
|
|
224
|
+
height: number;
|
|
225
|
+
sizeBytes: number;
|
|
226
|
+
}[];
|
|
227
|
+
};
|
|
228
|
+
declare function formatMessageImage(i: MessageImage): {
|
|
229
|
+
imageId: string;
|
|
230
|
+
/** `"image/png"`, `"image/jpeg"` or `"image/webp"`. */
|
|
231
|
+
mimeType: string;
|
|
232
|
+
/** Pixels; an image over 2000 pixels on a side is stored scaled down to fit. */
|
|
233
|
+
width: number;
|
|
234
|
+
height: number;
|
|
235
|
+
sizeBytes: number;
|
|
162
236
|
};
|
|
237
|
+
type AssistantMessageImage = ReturnType<typeof formatMessageImage>;
|
|
163
238
|
type AssistantMessage = ReturnType<typeof formatMessage>;
|
|
164
239
|
declare function formatMemory(m: Memory): {
|
|
165
240
|
memoryId: string;
|
|
@@ -221,6 +296,36 @@ declare function formatPrepareAssistantKeysResult(r: PrepareAssistantKeysRespons
|
|
|
221
296
|
expiresAt: number | undefined;
|
|
222
297
|
};
|
|
223
298
|
type PrepareAssistantKeysResult = ReturnType<typeof formatPrepareAssistantKeysResult>;
|
|
299
|
+
/** The caller's own OpenAI API key as the assistant shows it; the key itself is never returned. */
|
|
300
|
+
declare function formatModelKey(k: ModelKey | undefined): {
|
|
301
|
+
/** The key's last four characters, e.g. `"x7Qa"`. */
|
|
302
|
+
suffix: string;
|
|
303
|
+
addedAt: number | undefined;
|
|
304
|
+
/** The last check with OpenAI: on save, when OpenAI refused it in a run, and on recovery. */
|
|
305
|
+
lastCheck: "unspecified" | "valid" | "rejected" | "no_quota" | "model_unavailable";
|
|
306
|
+
checkedAt: number | undefined;
|
|
307
|
+
};
|
|
308
|
+
type AssistantModelKey = ReturnType<typeof formatModelKey>;
|
|
309
|
+
/** Credits are the main account's, shared by every subaccount. */
|
|
310
|
+
declare function formatAssistantUsage(r: GetUsageResponse): {
|
|
311
|
+
/** With `"own_key"`, messages use no credits. */
|
|
312
|
+
fundingMode: "credits" | "own_key";
|
|
313
|
+
/** Omitted when the tier could not be read; VIP 0's free credits then apply. */
|
|
314
|
+
vipTier: number | undefined;
|
|
315
|
+
/** Today's free credits. */
|
|
316
|
+
freeCredits: number;
|
|
317
|
+
/** Rounded down; may exceed `freeCredits`, as an answer started with credits left finishes. */
|
|
318
|
+
freeCreditsUsed: number;
|
|
319
|
+
freeCreditsLeft: number;
|
|
320
|
+
/** Epoch ms of the next 00:00 UTC; unused credits do not carry over. */
|
|
321
|
+
resetsAt: number | undefined;
|
|
322
|
+
/** The next VIP tier's daily free credits; omitted at the top tier or an unknown tier. */
|
|
323
|
+
nextTier: {
|
|
324
|
+
vipTier: number;
|
|
325
|
+
dailyFreeCredits: number;
|
|
326
|
+
} | undefined;
|
|
327
|
+
};
|
|
328
|
+
type AssistantUsage = ReturnType<typeof formatAssistantUsage>;
|
|
224
329
|
/** `nextPageToken` is empty when no more results exist. */
|
|
225
330
|
type ListAssistantConversationsResult = {
|
|
226
331
|
conversations: AssistantConversation[];
|
|
@@ -247,5 +352,5 @@ type TelegramApprovalLimits = {
|
|
|
247
352
|
dailyUsd: string | null;
|
|
248
353
|
};
|
|
249
354
|
//#endregion
|
|
250
|
-
export { AssistantConversation, AssistantKey, AssistantMemory, AssistantMessage, AssistantRunIdInput, AssistantRunIdInputSchema, CompleteAssistantKeysInput, CompleteAssistantKeysInputSchema, DecideAssistantApprovalInput, DecideAssistantApprovalInputSchema, DeleteAssistantMemoryInput, DeleteAssistantMemoryInputSchema, ListAssistantConversationsInput, ListAssistantConversationsInputSchema, ListAssistantConversationsResult, ListAssistantKeysInput, ListAssistantKeysInputSchema, ListAssistantMemoriesInput, ListAssistantMemoriesInputSchema, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesInputSchema, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysInputSchema, PrepareAssistantKeysResult, PreparedAssistantKey, SendAssistantMessageInput, SendAssistantMessageInputSchema, SetTelegramApprovalLimitsInput, SetTelegramApprovalLimitsInputSchema, TelegramApprovalLimits, WatchAssistantRunInput, WatchAssistantRunInputSchema, formatAssistantKey, formatConversation, formatMemory, formatMessage, formatPrepareAssistantKeysResult, formatPreparedAssistantKey };
|
|
355
|
+
export { AssistantConversation, AssistantKey, AssistantMemory, AssistantMessage, AssistantMessageImage, AssistantModelKey, AssistantRunIdInput, AssistantRunIdInputSchema, AssistantUsage, CompleteAssistantKeysInput, CompleteAssistantKeysInputSchema, DecideAssistantApprovalInput, DecideAssistantApprovalInputSchema, DeleteAssistantMemoryInput, DeleteAssistantMemoryInputSchema, GetAssistantMessageImageInput, GetAssistantMessageImageInputSchema, ListAssistantConversationsInput, ListAssistantConversationsInputSchema, ListAssistantConversationsResult, ListAssistantKeysInput, ListAssistantKeysInputSchema, ListAssistantMemoriesInput, ListAssistantMemoriesInputSchema, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesInputSchema, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysInputSchema, PrepareAssistantKeysResult, PreparedAssistantKey, SendAssistantMessageInput, SendAssistantMessageInputSchema, SetAssistantModelKeyInput, SetAssistantModelKeyInputSchema, SetTelegramApprovalLimitsInput, SetTelegramApprovalLimitsInputSchema, TelegramApprovalLimits, WatchAssistantRunInput, WatchAssistantRunInputSchema, formatAssistantKey, formatAssistantUsage, formatConversation, formatMemory, formatMessage, formatMessageImage, formatModelKey, formatPrepareAssistantKeysResult, formatPreparedAssistantKey };
|
|
251
356
|
//# sourceMappingURL=assistant.schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.schemas.d.ts","names":[],"sources":["../../../src/services/assistant/assistant.schemas.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"assistant.schemas.d.ts","names":[],"sources":["../../../src/services/assistant/assistant.schemas.ts"],"mappings":";;;cAsEa,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuFhC,4BAA4B,EAAE,kBAAkB;cAE/C,2BAAyB,EAAA;;;KAE1B,sBAAsB,EAAE,kBAAkB;cAEzC,8BAA4B,EAAA,yBAAA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