Resolve stash merge conflicts: keep both inline-task and billing features

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
tusharmagar 2026-03-13 10:44:48 +05:30
parent 63a5af8f9a
commit 4f07f626b3
7 changed files with 118 additions and 1 deletions

View file

@ -0,0 +1,38 @@
import { getAccessToken } from '../models/gateway.js';
import { ROWBOAT_BILLING_BASE_URL } from '../config/env.js';
export interface BillingInfo {
subscriptionPlan: string | null;
subscriptionStatus: string | null;
trialUsed: boolean;
sanctionedCredits: number;
availableCredits: number;
}
export async function getBillingInfo(): Promise<BillingInfo> {
const accessToken = await getAccessToken();
const response = await fetch(`${ROWBOAT_BILLING_BASE_URL}/me`, {
headers: { Authorization: `Bearer ${accessToken}` },
});
if (!response.ok) {
throw new Error(`Billing API failed: ${response.status}`);
}
const body = await response.json() as {
customer: {
subscriptionPlan: string | null;
subscriptionStatus: string | null;
trialUsed: boolean;
};
usage: {
sanctionedCredits: number;
availableCredits: number;
};
};
return {
subscriptionPlan: body.customer.subscriptionPlan,
subscriptionStatus: body.customer.subscriptionStatus,
trialUsed: body.customer.trialUsed,
sanctionedCredits: body.usage.sanctionedCredits,
availableCredits: body.usage.availableCredits,
};
}

View file

@ -3,3 +3,6 @@ export const API_URL =
export const SUPABASE_PROJECT_URL =
process.env.SUPABASE_PROJECT_URL || 'http://127.0.0.1:54321';
export const ROWBOAT_BILLING_BASE_URL =
process.env.ROWBOAT_BILLING_BASE_URL || 'https://billing.staging.x.rowboatlabs.com';

View file

@ -7,7 +7,7 @@ import { getProviderConfig } from '../auth/providers.js';
import * as oauthClient from '../auth/oauth-client.js';
import { API_URL } from '../config/env.js';
async function getAccessToken(): Promise<string> {
export async function getAccessToken(): Promise<string> {
const oauthRepo = container.resolve<IOAuthRepo>('oauthRepo');
const { tokens } = await oauthRepo.read('rowboat');
if (!tokens) {

View file

@ -473,6 +473,17 @@ const ipcSchemas = {
]).nullable(),
}),
},
// Billing channels
'billing:getInfo': {
req: z.null(),
res: z.object({
subscriptionPlan: z.string().nullable(),
subscriptionStatus: z.string().nullable(),
trialUsed: z.boolean(),
sanctionedCredits: z.number(),
availableCredits: z.number(),
}),
},
} as const;
// ============================================================================