GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — wip: cloud · josephschmitt/opencode@4e629c5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cloud
    • app/src/routes
      • gateway/v1/chat
        • completions.ts
      • stripe
        • webhook.ts
    • core/src
      • billing.ts
      • workspace.ts
    • function
      • src
        • gateway.ts
      • sst-env.d.ts
    • resource
      • sst-env.d.ts
  • infra
    • cloud.ts
  • opencode.json
  • packages/function
    • sst-env.d.ts
  • sst-env.d.ts
  • sst.config.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cloud/app/src/routes/gateway/v1/chat/completions.ts‎

Copy file name to clipboardExpand all lines: cloud/app/src/routes/gateway/v1/chat/completions.ts
+264-535Lines changed: 264 additions & 535 deletions
Large diffs are not rendered by default.
Collapse file

‎cloud/app/src/routes/stripe/webhook.ts‎

Copy file name to clipboardExpand all lines: cloud/app/src/routes/stripe/webhook.ts
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ export async function POST(input: APIEvent) {
2424
if (!workspaceID) throw new Error("Workspace ID not found")
2525
if (!customerID) throw new Error("Customer ID not found")
2626
if (!amount) throw new Error("Amount not found")
27+
if (amount !== 2118) throw new Error("Amount mismatch")
2728
if (!paymentID) throw new Error("Payment ID not found")
2829

30+
const chargedAmount = 2000
31+
2932
await Actor.provide("system", { workspaceID }, async () => {
3033
const customer = await Billing.get()
3134
if (customer?.customerID && customer.customerID !== customerID) throw new Error("Customer ID mismatch")
@@ -50,7 +53,7 @@ export async function POST(input: APIEvent) {
5053
await tx
5154
.update(BillingTable)
5255
.set({
53-
balance: sql`${BillingTable.balance} + ${centsToMicroCents(amount)}`,
56+
balance: sql`${BillingTable.balance} + ${centsToMicroCents(chargedAmount)}`,
5457
customerID,
5558
paymentMethodID: paymentMethod.id,
5659
paymentMethodLast4: paymentMethod.card!.last4,
@@ -59,7 +62,7 @@ export async function POST(input: APIEvent) {
5962
await tx.insert(PaymentTable).values({
6063
workspaceID,
6164
id: Identifier.create("payment"),
62-
amount: centsToMicroCents(amount),
65+
amount: centsToMicroCents(chargedAmount),
6366
paymentID,
6467
customerID,
6568
})
Collapse file

‎cloud/core/src/billing.ts‎

Copy file name to clipboardExpand all lines: cloud/core/src/billing.ts
+1-38Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,6 @@ export namespace Billing {
5252
)
5353
}
5454

55-
export const consume = fn(
56-
z.object({
57-
requestID: z.string().optional(),
58-
model: z.string(),
59-
inputTokens: z.number(),
60-
outputTokens: z.number(),
61-
reasoningTokens: z.number().optional(),
62-
cacheReadTokens: z.number().optional(),
63-
cacheWriteTokens: z.number().optional(),
64-
costInCents: z.number(),
65-
}),
66-
async (input) => {
67-
const workspaceID = Actor.workspace()
68-
const cost = centsToMicroCents(input.costInCents)
69-
70-
return await Database.transaction(async (tx) => {
71-
await tx.insert(UsageTable).values({
72-
workspaceID,
73-
id: Identifier.create("usage"),
74-
model: input.model,
75-
inputTokens: input.inputTokens,
76-
outputTokens: input.outputTokens,
77-
reasoningTokens: input.reasoningTokens,
78-
cacheReadTokens: input.cacheReadTokens,
79-
cacheWriteTokens: input.cacheWriteTokens,
80-
cost,
81-
})
82-
await tx
83-
.update(BillingTable)
84-
.set({
85-
balance: sql`${BillingTable.balance} - ${cost}`,
86-
})
87-
.where(eq(BillingTable.workspaceID, workspaceID))
88-
})
89-
},
90-
)
91-
9255
export const generateCheckoutUrl = fn(
9356
z.object({
9457
successUrl: z.string(),
@@ -109,7 +72,7 @@ export namespace Billing {
10972
product_data: {
11073
name: "opencode credits",
11174
},
112-
unit_amount: 2000, // $20 minimum
75+
unit_amount: 2118, // $20 minimum + Stripe fee 4.4% + $0.30
11376
},
11477
quantity: 1,
11578
},
Collapse file

‎cloud/core/src/workspace.ts‎

Copy file name to clipboardExpand all lines: cloud/core/src/workspace.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export namespace Workspace {
2626
await tx.insert(BillingTable).values({
2727
workspaceID,
2828
id: Identifier.create("billing"),
29-
balance: centsToMicroCents(100),
29+
balance: 0,
3030
})
3131
})
3232
await Actor.provide(

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.