@flashbacktech/tsclient 0.4.33 → 0.4.36

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/dist/index.d.cts CHANGED
@@ -822,7 +822,7 @@ interface ClarificationOption {
822
822
  label: string;
823
823
  description?: string;
824
824
  }
825
- type ChatEventType = 'phase' | 'question' | 'plan_draft' | 'step_started' | 'step_completed' | 'step_failed' | 'step_progress' | 'narration' | 'assistant_message' | 'done' | 'session_title' | 'tool_call_started' | 'tool_call_finished' | 'llm_call_finished' | 'tool_call_confirmation_required';
825
+ type ChatEventType = 'phase' | 'question' | 'plan_draft' | 'step_started' | 'step_completed' | 'step_failed' | 'step_progress' | 'narration' | 'assistant_message' | 'done' | 'session_title' | 'tool_call_started' | 'tool_call_finished' | 'llm_call_finished' | 'tool_call_confirmation_required' | 'chat_compaction_fired' | 'chat_checkpointed';
826
826
  type ChatPhase = 'classifying' | 'clarifying' | 'executing' | 'answering' | 'done';
827
827
  interface ChatPhasePayload {
828
828
  phase: ChatPhase;
@@ -957,13 +957,38 @@ interface ChatDonePayload {
957
957
  interface ChatSessionTitlePayload {
958
958
  title: string;
959
959
  }
960
+ /**
961
+ * Sent with `chat_compaction_fired` once per Run when the chat-loop
962
+ * mid-session replaces older history with a structured progress note
963
+ * (chat-compact-optimization Front #1). The session-debug view uses
964
+ * this to mark the boundary in the rendered transcript so operators
965
+ * can see how aggressively the loop is trimming context.
966
+ */
967
+ interface ChatCompactionFiredPayload {
968
+ turn_index: number;
969
+ prompt_tokens_before: number;
970
+ compactor_model: string;
971
+ }
972
+ /**
973
+ * Sent with `chat_checkpointed` when the chat-loop, on its final
974
+ * allowed iteration, emits a structured terminal summary instead of
975
+ * running another open-ended LLM call (chat-compact-optimization Front
976
+ * #2). The accompanying assistant message is the checkpoint body; the
977
+ * dashboard should render the session's StopReason
978
+ * ("max_turns_checkpointed") with a distinct chip and offer a "Continue
979
+ * this work" affordance that POSTs a canned follow-up.
980
+ */
981
+ interface ChatCheckpointedPayload {
982
+ turn_index: number;
983
+ checkpoint_model: string;
984
+ }
960
985
  interface ChatEvent {
961
986
  conversation_id: string;
962
987
  turn_id: string;
963
988
  type: ChatEventType;
964
989
  plan_id?: string;
965
990
  step_id?: string;
966
- payload?: ChatPhasePayload | ChatQuestionPayload | ChatPlanDraftPayload | ChatStepEventPayload | ChatStepProgressPayload | ChatNarrationPayload | ChatAssistantMessagePayload | ChatDonePayload | ChatSessionTitlePayload | ChatToolCallStartedPayload | ChatToolCallFinishedPayload | ChatLLMCallFinishedPayload | ChatToolCallConfirmationRequiredPayload | unknown;
991
+ payload?: ChatPhasePayload | ChatQuestionPayload | ChatPlanDraftPayload | ChatStepEventPayload | ChatStepProgressPayload | ChatNarrationPayload | ChatAssistantMessagePayload | ChatDonePayload | ChatSessionTitlePayload | ChatToolCallStartedPayload | ChatToolCallFinishedPayload | ChatLLMCallFinishedPayload | ChatToolCallConfirmationRequiredPayload | ChatCompactionFiredPayload | ChatCheckpointedPayload | unknown;
967
992
  timestamp: string;
968
993
  event_id?: number;
969
994
  }
@@ -1510,8 +1535,8 @@ interface SubscriptionPeriod {
1510
1535
  currency: string;
1511
1536
  interval: string;
1512
1537
  intervalCount?: number;
1513
- /** Per-period grant in USD-cents. 0 means no grant attached. */
1514
- creditsGrantedCents: number;
1538
+ /** Per-period grant in USD micros. 0 means no grant attached. */
1539
+ creditsGrantedMicros: number;
1515
1540
  }
1516
1541
  interface SubscriptionCapability {
1517
1542
  key: string;
@@ -1524,8 +1549,8 @@ interface Subscription {
1524
1549
  description?: string;
1525
1550
  periods: SubscriptionPeriod[];
1526
1551
  capabilities: SubscriptionCapability[];
1527
- /** Plan-level 24h rolling debit cap in USD-cents. null = no cap. */
1528
- dailyCreditCapCents?: number | null;
1552
+ /** Plan-level 24h rolling debit cap in USD micros. null = no cap. */
1553
+ dailyCreditCapMicros?: number | null;
1529
1554
  }
1530
1555
  interface OrgSubscription {
1531
1556
  id: string;
@@ -1571,28 +1596,24 @@ interface ListPaymentsResponse {
1571
1596
  /**
1572
1597
  * Org credit balance — two-bucket forfeit model (billing-v1).
1573
1598
  *
1574
- * - permanentCreditCents: PAYG (credit-pack) bucket. Never expires.
1575
- * - subscriptionCreditCents: Current subscription cycle. Forfeit on
1576
- * renewal; expires at subscriptionCreditExpiresAt.
1577
- * - subscriptionCreditExpiresAt: ISO-8601; null when no subscription is active.
1578
- * - totalActiveCents: Pre-computed sum = permanent +
1579
- * (subscription if not expired). Use this
1580
- * to drive the daily-cap progress bar
1581
- * and "out of credits" check.
1582
- *
1583
- * Format `(value / 100).toFixed(2)` for display. Drain order is
1584
- * subscription bucket first, then permanent — visualise as a single
1585
- * pool with a small "expires soon" tag for the subscription slice.
1599
+ * - permanentCreditMicros: PAYG (credit-pack) bucket. Never expires.
1600
+ * - subscriptionCreditMicros: Current subscription cycle. Forfeit on
1601
+ * renewal; expires at subscriptionCreditExpiresAt.
1602
+ * - subscriptionCreditExpiresAt: ISO-8601; null when no subscription is active.
1603
+ * - totalActiveMicros: Pre-computed sum = permanent +
1604
+ * (subscription if not expired). Use this
1605
+ * to drive the daily-cap progress bar
1606
+ * and "out of credits" check.
1586
1607
  *
1587
- * Legacy `realtimeBalance` / `pendingConsumption` / `breakdown` /
1588
- * `dateBalance` fields were dropped: the chat-loop debits in real-time
1589
- * so there is no notion of "pending".
1608
+ * Format `(value / 1_000_000).toFixed(2)` for dollar layouts. Drain
1609
+ * order is subscription bucket first, then permanent visualise as a
1610
+ * single pool with a small "expires soon" tag for the subscription slice.
1590
1611
  */
1591
1612
  interface CreditBalance {
1592
- permanentCreditCents: number;
1593
- subscriptionCreditCents: number;
1613
+ permanentCreditMicros: number;
1614
+ subscriptionCreditMicros: number;
1594
1615
  subscriptionCreditExpiresAt: string | null;
1595
- totalActiveCents: number;
1616
+ totalActiveMicros: number;
1596
1617
  }
1597
1618
  /** Source of a credit ledger row. Matches the kind enum from migration 0017. */
1598
1619
  type CreditTransactionKind = 'grant_initial' | 'grant_renewal' | 'grant_pack' | 'debit_llm' | 'debit_sandbox' | 'admin_adjust';
@@ -1600,8 +1621,8 @@ type CreditTransactionKind = 'grant_initial' | 'grant_renewal' | 'grant_pack' |
1600
1621
  type CreditTransactionType = 'consumption' | 'purchase' | 'grant';
1601
1622
  interface CreditTransaction {
1602
1623
  id: string;
1603
- /** Signed amount in USD-cents. Negative = debit. */
1604
- creditAmountCents: number;
1624
+ /** Signed amount in USD micros. Negative = debit. */
1625
+ creditAmountMicros: number;
1605
1626
  kind: CreditTransactionKind;
1606
1627
  type: CreditTransactionType;
1607
1628
  description?: string;
@@ -1628,13 +1649,47 @@ interface ListCreditsTransactionsResponse {
1628
1649
  limit: number;
1629
1650
  };
1630
1651
  }
1631
- /** One month's bucket of credit activity. All money values in USD-cents. */
1652
+ /** One month's bucket of credit activity. All money values in USD micros. */
1632
1653
  interface MonthlyCreditStats {
1633
1654
  month: string;
1634
- consumptionCents: number;
1635
- purchasesCents: number;
1636
- grantsCents: number;
1637
- balanceCents: number;
1655
+ consumptionMicros: number;
1656
+ purchasesMicros: number;
1657
+ grantsMicros: number;
1658
+ balanceMicros: number;
1659
+ }
1660
+ /**
1661
+ * "Other amount" PAYG purchase config, served by
1662
+ * GET /credits/packs/custom-config. Disabled =>
1663
+ * `{ enabled: false, minMicros: 0, maxMicros: 0, presetMicros: [] }` so
1664
+ * the frontend can hide the tile cleanly without nil checks.
1665
+ */
1666
+ interface CustomCreditPurchaseConfig {
1667
+ enabled: boolean;
1668
+ minMicros: number;
1669
+ maxMicros: number;
1670
+ /** Suggested one-click amounts (in USD micros) for the "Other" tile. */
1671
+ presetMicros: number[];
1672
+ }
1673
+ /**
1674
+ * Body for POST /credits/packs/buy-custom. `amountMicros` is the
1675
+ * arbitrary dollar amount the user typed, converted to USD micros
1676
+ * before the API call. Server enforces `min <= amount <= max`.
1677
+ * Credit ratio is 1:1 (pay $X, get $X of credits in the permanent
1678
+ * bucket). Stripe charges in cents — the backend divides by 10000 at
1679
+ * the API boundary, so amounts that aren't multiples of 10000 micros
1680
+ * incur tiny rounding loss at the Stripe step (presetMicros + minMicros
1681
+ * should be 10000-aligned).
1682
+ */
1683
+ interface BuyCustomCreditRequest {
1684
+ amountMicros: number;
1685
+ }
1686
+ /** Response from POST /credits/packs/buy-custom. Mirrors the fixed-pack response. */
1687
+ interface BuyCustomCreditResponse {
1688
+ success: boolean;
1689
+ checkoutUrl?: string;
1690
+ sessionId?: string;
1691
+ error_code?: string;
1692
+ message?: string;
1638
1693
  }
1639
1694
  /**
1640
1695
  * Refusal reasons from POST /v1/agent/chat/sessions/:id/messages when
@@ -1645,12 +1700,12 @@ type ChatBillingRefuseCode = 'out_of_credits' | 'daily_cap_reached' | 'no_subscr
1645
1700
  interface ChatBillingRefuseError {
1646
1701
  message: string;
1647
1702
  code: ChatBillingRefuseCode;
1648
- permanentCreditCents: number;
1649
- subscriptionCreditCents: number;
1703
+ permanentCreditMicros: number;
1704
+ subscriptionCreditMicros: number;
1650
1705
  subscriptionCreditExpiresAt: string | null;
1651
- totalActiveCents: number;
1652
- dailyCapCents: number;
1653
- debitedLast24hCents: number;
1706
+ totalActiveMicros: number;
1707
+ dailyCapMicros: number;
1708
+ debitedLast24hMicros: number;
1654
1709
  }
1655
1710
 
1656
1711
  declare class SubscriptionsClient {
@@ -1674,6 +1729,20 @@ declare class CreditsClient {
1674
1729
  listTransactions(query?: ListCreditsTransactionsQuery): Promise<ListCreditsTransactionsResponse>;
1675
1730
  /** Backend currently returns 501. Surfaced for forward-compat. */
1676
1731
  getMonthlyStats(): Promise<MonthlyCreditStats[]>;
1732
+ /**
1733
+ * "Other amount" PAYG config — bounds + presets for the
1734
+ * arbitrary-dollar tile. Public endpoint; returns a disabled
1735
+ * shape (`enabled: false`) when the feature is off so the
1736
+ * frontend can hide the tile without throwing.
1737
+ */
1738
+ getCustomConfig(): Promise<CustomCreditPurchaseConfig>;
1739
+ /**
1740
+ * Buy an arbitrary-dollar PAYG amount. The Stripe Checkout
1741
+ * session is built with `price_data` inline (no pre-created
1742
+ * Price), so the catalog has nothing to provision for this — it
1743
+ * is purely a per-purchase flow.
1744
+ */
1745
+ buyCustom(body: BuyCustomCreditRequest): Promise<BuyCustomCreditResponse>;
1677
1746
  }
1678
1747
 
1679
1748
  interface UsageWindow {
@@ -1950,4 +2019,4 @@ declare class NotImplementedError extends Error {
1950
2019
  constructor(method: string);
1951
2020
  }
1952
2021
 
1953
- export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AuthUser, BaseClient, type BaseClientOptions, type BudgetScope, BudgetsClient, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type ModeType, type MonthlyCreditStats, NotImplementedError, type OpenChatStreamOptions, type OrgBudget, OrgRoles, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type Query, type ReconcileScope, type ReconcileTuple, type RefreshRequest, type RegisterRequest, type RequestOptions, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
2022
+ export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AuthUser, BaseClient, type BaseClientOptions, type BudgetScope, BudgetsClient, type BuyCustomCreditRequest, type BuyCustomCreditResponse, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatCheckpointedPayload, type ChatCompactionFiredPayload, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type CustomCreditPurchaseConfig, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type ModeType, type MonthlyCreditStats, NotImplementedError, type OpenChatStreamOptions, type OrgBudget, OrgRoles, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type Query, type ReconcileScope, type ReconcileTuple, type RefreshRequest, type RegisterRequest, type RequestOptions, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
package/dist/index.d.ts CHANGED
@@ -822,7 +822,7 @@ interface ClarificationOption {
822
822
  label: string;
823
823
  description?: string;
824
824
  }
825
- type ChatEventType = 'phase' | 'question' | 'plan_draft' | 'step_started' | 'step_completed' | 'step_failed' | 'step_progress' | 'narration' | 'assistant_message' | 'done' | 'session_title' | 'tool_call_started' | 'tool_call_finished' | 'llm_call_finished' | 'tool_call_confirmation_required';
825
+ type ChatEventType = 'phase' | 'question' | 'plan_draft' | 'step_started' | 'step_completed' | 'step_failed' | 'step_progress' | 'narration' | 'assistant_message' | 'done' | 'session_title' | 'tool_call_started' | 'tool_call_finished' | 'llm_call_finished' | 'tool_call_confirmation_required' | 'chat_compaction_fired' | 'chat_checkpointed';
826
826
  type ChatPhase = 'classifying' | 'clarifying' | 'executing' | 'answering' | 'done';
827
827
  interface ChatPhasePayload {
828
828
  phase: ChatPhase;
@@ -957,13 +957,38 @@ interface ChatDonePayload {
957
957
  interface ChatSessionTitlePayload {
958
958
  title: string;
959
959
  }
960
+ /**
961
+ * Sent with `chat_compaction_fired` once per Run when the chat-loop
962
+ * mid-session replaces older history with a structured progress note
963
+ * (chat-compact-optimization Front #1). The session-debug view uses
964
+ * this to mark the boundary in the rendered transcript so operators
965
+ * can see how aggressively the loop is trimming context.
966
+ */
967
+ interface ChatCompactionFiredPayload {
968
+ turn_index: number;
969
+ prompt_tokens_before: number;
970
+ compactor_model: string;
971
+ }
972
+ /**
973
+ * Sent with `chat_checkpointed` when the chat-loop, on its final
974
+ * allowed iteration, emits a structured terminal summary instead of
975
+ * running another open-ended LLM call (chat-compact-optimization Front
976
+ * #2). The accompanying assistant message is the checkpoint body; the
977
+ * dashboard should render the session's StopReason
978
+ * ("max_turns_checkpointed") with a distinct chip and offer a "Continue
979
+ * this work" affordance that POSTs a canned follow-up.
980
+ */
981
+ interface ChatCheckpointedPayload {
982
+ turn_index: number;
983
+ checkpoint_model: string;
984
+ }
960
985
  interface ChatEvent {
961
986
  conversation_id: string;
962
987
  turn_id: string;
963
988
  type: ChatEventType;
964
989
  plan_id?: string;
965
990
  step_id?: string;
966
- payload?: ChatPhasePayload | ChatQuestionPayload | ChatPlanDraftPayload | ChatStepEventPayload | ChatStepProgressPayload | ChatNarrationPayload | ChatAssistantMessagePayload | ChatDonePayload | ChatSessionTitlePayload | ChatToolCallStartedPayload | ChatToolCallFinishedPayload | ChatLLMCallFinishedPayload | ChatToolCallConfirmationRequiredPayload | unknown;
991
+ payload?: ChatPhasePayload | ChatQuestionPayload | ChatPlanDraftPayload | ChatStepEventPayload | ChatStepProgressPayload | ChatNarrationPayload | ChatAssistantMessagePayload | ChatDonePayload | ChatSessionTitlePayload | ChatToolCallStartedPayload | ChatToolCallFinishedPayload | ChatLLMCallFinishedPayload | ChatToolCallConfirmationRequiredPayload | ChatCompactionFiredPayload | ChatCheckpointedPayload | unknown;
967
992
  timestamp: string;
968
993
  event_id?: number;
969
994
  }
@@ -1510,8 +1535,8 @@ interface SubscriptionPeriod {
1510
1535
  currency: string;
1511
1536
  interval: string;
1512
1537
  intervalCount?: number;
1513
- /** Per-period grant in USD-cents. 0 means no grant attached. */
1514
- creditsGrantedCents: number;
1538
+ /** Per-period grant in USD micros. 0 means no grant attached. */
1539
+ creditsGrantedMicros: number;
1515
1540
  }
1516
1541
  interface SubscriptionCapability {
1517
1542
  key: string;
@@ -1524,8 +1549,8 @@ interface Subscription {
1524
1549
  description?: string;
1525
1550
  periods: SubscriptionPeriod[];
1526
1551
  capabilities: SubscriptionCapability[];
1527
- /** Plan-level 24h rolling debit cap in USD-cents. null = no cap. */
1528
- dailyCreditCapCents?: number | null;
1552
+ /** Plan-level 24h rolling debit cap in USD micros. null = no cap. */
1553
+ dailyCreditCapMicros?: number | null;
1529
1554
  }
1530
1555
  interface OrgSubscription {
1531
1556
  id: string;
@@ -1571,28 +1596,24 @@ interface ListPaymentsResponse {
1571
1596
  /**
1572
1597
  * Org credit balance — two-bucket forfeit model (billing-v1).
1573
1598
  *
1574
- * - permanentCreditCents: PAYG (credit-pack) bucket. Never expires.
1575
- * - subscriptionCreditCents: Current subscription cycle. Forfeit on
1576
- * renewal; expires at subscriptionCreditExpiresAt.
1577
- * - subscriptionCreditExpiresAt: ISO-8601; null when no subscription is active.
1578
- * - totalActiveCents: Pre-computed sum = permanent +
1579
- * (subscription if not expired). Use this
1580
- * to drive the daily-cap progress bar
1581
- * and "out of credits" check.
1582
- *
1583
- * Format `(value / 100).toFixed(2)` for display. Drain order is
1584
- * subscription bucket first, then permanent — visualise as a single
1585
- * pool with a small "expires soon" tag for the subscription slice.
1599
+ * - permanentCreditMicros: PAYG (credit-pack) bucket. Never expires.
1600
+ * - subscriptionCreditMicros: Current subscription cycle. Forfeit on
1601
+ * renewal; expires at subscriptionCreditExpiresAt.
1602
+ * - subscriptionCreditExpiresAt: ISO-8601; null when no subscription is active.
1603
+ * - totalActiveMicros: Pre-computed sum = permanent +
1604
+ * (subscription if not expired). Use this
1605
+ * to drive the daily-cap progress bar
1606
+ * and "out of credits" check.
1586
1607
  *
1587
- * Legacy `realtimeBalance` / `pendingConsumption` / `breakdown` /
1588
- * `dateBalance` fields were dropped: the chat-loop debits in real-time
1589
- * so there is no notion of "pending".
1608
+ * Format `(value / 1_000_000).toFixed(2)` for dollar layouts. Drain
1609
+ * order is subscription bucket first, then permanent visualise as a
1610
+ * single pool with a small "expires soon" tag for the subscription slice.
1590
1611
  */
1591
1612
  interface CreditBalance {
1592
- permanentCreditCents: number;
1593
- subscriptionCreditCents: number;
1613
+ permanentCreditMicros: number;
1614
+ subscriptionCreditMicros: number;
1594
1615
  subscriptionCreditExpiresAt: string | null;
1595
- totalActiveCents: number;
1616
+ totalActiveMicros: number;
1596
1617
  }
1597
1618
  /** Source of a credit ledger row. Matches the kind enum from migration 0017. */
1598
1619
  type CreditTransactionKind = 'grant_initial' | 'grant_renewal' | 'grant_pack' | 'debit_llm' | 'debit_sandbox' | 'admin_adjust';
@@ -1600,8 +1621,8 @@ type CreditTransactionKind = 'grant_initial' | 'grant_renewal' | 'grant_pack' |
1600
1621
  type CreditTransactionType = 'consumption' | 'purchase' | 'grant';
1601
1622
  interface CreditTransaction {
1602
1623
  id: string;
1603
- /** Signed amount in USD-cents. Negative = debit. */
1604
- creditAmountCents: number;
1624
+ /** Signed amount in USD micros. Negative = debit. */
1625
+ creditAmountMicros: number;
1605
1626
  kind: CreditTransactionKind;
1606
1627
  type: CreditTransactionType;
1607
1628
  description?: string;
@@ -1628,13 +1649,47 @@ interface ListCreditsTransactionsResponse {
1628
1649
  limit: number;
1629
1650
  };
1630
1651
  }
1631
- /** One month's bucket of credit activity. All money values in USD-cents. */
1652
+ /** One month's bucket of credit activity. All money values in USD micros. */
1632
1653
  interface MonthlyCreditStats {
1633
1654
  month: string;
1634
- consumptionCents: number;
1635
- purchasesCents: number;
1636
- grantsCents: number;
1637
- balanceCents: number;
1655
+ consumptionMicros: number;
1656
+ purchasesMicros: number;
1657
+ grantsMicros: number;
1658
+ balanceMicros: number;
1659
+ }
1660
+ /**
1661
+ * "Other amount" PAYG purchase config, served by
1662
+ * GET /credits/packs/custom-config. Disabled =>
1663
+ * `{ enabled: false, minMicros: 0, maxMicros: 0, presetMicros: [] }` so
1664
+ * the frontend can hide the tile cleanly without nil checks.
1665
+ */
1666
+ interface CustomCreditPurchaseConfig {
1667
+ enabled: boolean;
1668
+ minMicros: number;
1669
+ maxMicros: number;
1670
+ /** Suggested one-click amounts (in USD micros) for the "Other" tile. */
1671
+ presetMicros: number[];
1672
+ }
1673
+ /**
1674
+ * Body for POST /credits/packs/buy-custom. `amountMicros` is the
1675
+ * arbitrary dollar amount the user typed, converted to USD micros
1676
+ * before the API call. Server enforces `min <= amount <= max`.
1677
+ * Credit ratio is 1:1 (pay $X, get $X of credits in the permanent
1678
+ * bucket). Stripe charges in cents — the backend divides by 10000 at
1679
+ * the API boundary, so amounts that aren't multiples of 10000 micros
1680
+ * incur tiny rounding loss at the Stripe step (presetMicros + minMicros
1681
+ * should be 10000-aligned).
1682
+ */
1683
+ interface BuyCustomCreditRequest {
1684
+ amountMicros: number;
1685
+ }
1686
+ /** Response from POST /credits/packs/buy-custom. Mirrors the fixed-pack response. */
1687
+ interface BuyCustomCreditResponse {
1688
+ success: boolean;
1689
+ checkoutUrl?: string;
1690
+ sessionId?: string;
1691
+ error_code?: string;
1692
+ message?: string;
1638
1693
  }
1639
1694
  /**
1640
1695
  * Refusal reasons from POST /v1/agent/chat/sessions/:id/messages when
@@ -1645,12 +1700,12 @@ type ChatBillingRefuseCode = 'out_of_credits' | 'daily_cap_reached' | 'no_subscr
1645
1700
  interface ChatBillingRefuseError {
1646
1701
  message: string;
1647
1702
  code: ChatBillingRefuseCode;
1648
- permanentCreditCents: number;
1649
- subscriptionCreditCents: number;
1703
+ permanentCreditMicros: number;
1704
+ subscriptionCreditMicros: number;
1650
1705
  subscriptionCreditExpiresAt: string | null;
1651
- totalActiveCents: number;
1652
- dailyCapCents: number;
1653
- debitedLast24hCents: number;
1706
+ totalActiveMicros: number;
1707
+ dailyCapMicros: number;
1708
+ debitedLast24hMicros: number;
1654
1709
  }
1655
1710
 
1656
1711
  declare class SubscriptionsClient {
@@ -1674,6 +1729,20 @@ declare class CreditsClient {
1674
1729
  listTransactions(query?: ListCreditsTransactionsQuery): Promise<ListCreditsTransactionsResponse>;
1675
1730
  /** Backend currently returns 501. Surfaced for forward-compat. */
1676
1731
  getMonthlyStats(): Promise<MonthlyCreditStats[]>;
1732
+ /**
1733
+ * "Other amount" PAYG config — bounds + presets for the
1734
+ * arbitrary-dollar tile. Public endpoint; returns a disabled
1735
+ * shape (`enabled: false`) when the feature is off so the
1736
+ * frontend can hide the tile without throwing.
1737
+ */
1738
+ getCustomConfig(): Promise<CustomCreditPurchaseConfig>;
1739
+ /**
1740
+ * Buy an arbitrary-dollar PAYG amount. The Stripe Checkout
1741
+ * session is built with `price_data` inline (no pre-created
1742
+ * Price), so the catalog has nothing to provision for this — it
1743
+ * is purely a per-purchase flow.
1744
+ */
1745
+ buyCustom(body: BuyCustomCreditRequest): Promise<BuyCustomCreditResponse>;
1677
1746
  }
1678
1747
 
1679
1748
  interface UsageWindow {
@@ -1950,4 +2019,4 @@ declare class NotImplementedError extends Error {
1950
2019
  constructor(method: string);
1951
2020
  }
1952
2021
 
1953
- export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AuthUser, BaseClient, type BaseClientOptions, type BudgetScope, BudgetsClient, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type ModeType, type MonthlyCreditStats, NotImplementedError, type OpenChatStreamOptions, type OrgBudget, OrgRoles, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type Query, type ReconcileScope, type ReconcileTuple, type RefreshRequest, type RegisterRequest, type RequestOptions, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
2022
+ export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AuthUser, BaseClient, type BaseClientOptions, type BudgetScope, BudgetsClient, type BuyCustomCreditRequest, type BuyCustomCreditResponse, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatCheckpointedPayload, type ChatCompactionFiredPayload, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type CustomCreditPurchaseConfig, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type ModeType, type MonthlyCreditStats, NotImplementedError, type OpenChatStreamOptions, type OrgBudget, OrgRoles, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type Query, type ReconcileScope, type ReconcileTuple, type RefreshRequest, type RegisterRequest, type RequestOptions, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
package/dist/index.js CHANGED
@@ -964,6 +964,25 @@ var CreditsClient = class {
964
964
  const res = await this.http.get("/credits/stats/monthly");
965
965
  return res.data ?? [];
966
966
  }
967
+ /**
968
+ * "Other amount" PAYG config — bounds + presets for the
969
+ * arbitrary-dollar tile. Public endpoint; returns a disabled
970
+ * shape (`enabled: false`) when the feature is off so the
971
+ * frontend can hide the tile without throwing.
972
+ */
973
+ async getCustomConfig() {
974
+ const res = await this.http.get("/credits/packs/custom-config");
975
+ return unwrapData(res);
976
+ }
977
+ /**
978
+ * Buy an arbitrary-dollar PAYG amount. The Stripe Checkout
979
+ * session is built with `price_data` inline (no pre-created
980
+ * Price), so the catalog has nothing to provision for this — it
981
+ * is purely a per-purchase flow.
982
+ */
983
+ buyCustom(body) {
984
+ return this.http.post("/credits/packs/buy-custom", { body });
985
+ }
967
986
  };
968
987
 
969
988
  // src/modules/usage/UsageClient.ts