opencode-quota icon indicating copy to clipboard operation
opencode-quota copied to clipboard

[feature]: Add Opencode GO Provider (edit: added via scraping, tracking for API)

Open jesustrig opened this issue 7 months ago • 16 comments

Pre-flight checks

  • [x] I searched existing issues and did not find a duplicate request.
  • [x] I reviewed current behavior on the production released OpenCode version.

OpenCode version reviewed

1.3.17

Problem statement

I Use opencode GO subscription and wanna see usage and limits with opencode-quota

Proposed change

Add opencode GO provider to the list of supported providers, to see token usage and quota limits

Alternatives considered

No response

Acceptance criteria

No response

jesustrig avatar Apr 09 '26 06:04 jesustrig

I can't add it right now, but will add once Opencode adds a usage API. There is already an issue open: https://github.com/anomalyco/opencode/issues/16017, and PR open: https://github.com/anomalyco/opencode/pull/16513

slkiser avatar Apr 09 '26 23:04 slkiser

perfect! thanks for the reply @slkiser

thanks for the project ;)

I should close this issue, o keep open to track the issue in opencode?

Regards, jesús.

jesustrig avatar Apr 10 '26 03:04 jesustrig

We can keep it open so I don't forget :)

Happy the plugin is helpful!

slkiser avatar Apr 10 '26 12:04 slkiser

@jesustrig This feature was added by via dashboard scraping an API endpoint created by @vmvarela.

I am reopening this just to update and track when/if Opencode makes that API public.

slkiser avatar Apr 13 '26 14:04 slkiser

can we configure the feature to also show "Rolling Usage" and "Weekly Usage"

Izzur avatar Apr 22 '26 12:04 Izzur

Happy to extend it for the other quotas in GO.

I would need to know what the dashboard scraper needs to fetch, as I don't have a subscription.

slkiser avatar Apr 22 '26 13:04 slkiser

I attach sample html that seems to contain the relevant data

        <script>
            self.$R=self.$R||[];_$HY.r["userEmail[\\"wrk_RANDOMWORKSPACEID\\"]"]=$R[0]=($R[2]=r=>(r.p=new Promise((s,f)=>{r.s=s,r.f=f})))($R[1]={p:0,s:0,f:0});_$HY.r["00000001000000000001000000"]=$R[3]=$R[2]($R[4]={p:0,s:0,f:0});_$HY.r["workspaces[]"]=$R[5]=$R[2]($R[6]={p:0,s:0,f:0});_$HY.r["000000010000000000010000030"]=$R[7]=$R[2]($R[8]={p:0,s:0,f:0});_$HY.r["session.get[\\"wrk_RANDOMWORKSPACEID\\"]"]=$R[9]=$R[2]($R[10]={p:0,s:0,f:0});_$HY.r["00000001000000000001000005000"]=$R[11]=$R[2]($R[12]={p:0,s:0,f:0});_$HY.r["billing.get[\\"wrk_RANDOMWORKSPACEID\\"]"]=$R[13]=$R[2]($R[14]={p:0,s:0,f:0});_$HY.r["0000000100000000000100000500a140020"]=$R[15]=$R[2]($R[16]={p:0,s:0,f:0});_$HY.r["lite.subscription.get[\\"wrk_RANDOMWORKSPACEID\\"]"]=$R[17]=$R[2]($R[18]={p:0,s:0,f:0});_$HY.r["0000000100000000000100000500a140021"]=$R[19]=$R[2]($R[20]={p:0,s:0,f:0});_$HY.r["000000010000000000010"]=$R[21]=$R[2]($R[22]={p:0,s:0,f:0});($R[24]=(r,d)=>{r.s(d),r.p.s=1,r.p.v=d})($R[10],$R[23]={isAdmin:!0,isBeta:!1});$R[24]($R[12],$R[23]);$R[24]($R[14],$R[25]={customerID:"cus_RandomCustomerId",paymentMethodID:"pm_RandomPaymentMethodId",paymentMethodType:"card",paymentMethodLast4:"1234",balance:0,reload:null,reloadAmount:20,reloadAmountMin:10,reloadTrigger:5,reloadTriggerMin:5,monthlyLimit:null,monthlyUsage:null,timeMonthlyUsageUpdated:null,reloadError:null,timeReloadError:null,subscription:null,subscriptionID:null,subscriptionPlan:null,timeSubscriptionBooked:null,timeSubscriptionSelected:null,lite:$R[26]={},liteSubscriptionID:"sub_RandomSubscriptionId"});$R[24]($R[16],$R[25]);$R[24]($R[18],$R[27]={mine:!0,useBalance:!1,rollingUsage:$R[28]={status:"ok",resetInSec:5534,usagePercent:5},weeklyUsage:$R[29]={status:"ok",resetInSec:393031,usagePercent:2},monthlyUsage:$R[30]={status:"ok",resetInSec:2568896,usagePercent:1}});$R[24]($R[20],$R[27]);$R[24]($R[1],"[email protected]");$R[24]($R[4],"[email protected]");$R[24]($R[6],$R[31]=[$R[32]={id:"wrk_DEFAULTWORKSPACEID",name:"Default",slug:null},$R[33]={id:"wrk_RANDOMWORKSPACEID",name:"CurrentWorkspaceName",slug:null}]);$R[24]($R[8],$R[31]);$R[24]($R[22],!0);
        </script>

Izzur avatar Apr 22 '26 14:04 Izzur

can we configure the feature to also show "Rolling Usage" and "Weekly Usage"

solved in #65 or #62

tmih06 avatar Apr 27 '26 18:04 tmih06

This issue has been inactive for 23 days. It will be closed in 7 days if there is no further activity.

github-actions[bot] avatar May 21 '26 09:05 github-actions[bot]

Hi, I think OpenCode's dashboard updated an now it charges usage data differently, because the scrapper is not working for me even with all correctly configured ( opencode-go.json file with workspaceId and authcookie keys, quota-toast.json file with opencodeGoWindows key configured, etc) and all I receive is "Could not parse any known OpenCode Go dashboard usage windows (rollingUsage, weeklyUsage, monthlyUsage)"

Is this a real issue? Or something I'm doing wrong?

esteban387 avatar Jun 03 '26 11:06 esteban387

Hi, I think OpenCode's dashboard updated an now it charges usage data differently, because the scrapper is not working for me even with all correctly configured ( opencode-go.json file with workspaceId and authcookie keys, quota-toast.json file with opencodeGoWindows key configured, etc) and all I receive is "Could not parse any known OpenCode Go dashboard usage windows (rollingUsage, weeklyUsage, monthlyUsage)"

Is this a real issue? Or something I'm doing wrong?

+1 same problem

valentimarco avatar Jun 11 '26 09:06 valentimarco

@valentimarco @esteban387

Thanks for the reports. I don’t currently have enough safe/reproducible access to verify the OpenCode Go dashboard shape myself.

Could someone affected please open a dedicated issue for the current OpenCode Go dashboard scraper break?

I don't have a sub, so if someone could share any redacted evidence showing whether the dashboard HTML still contains:

  • rollingUsage
  • weeklyUsage
  • monthlyUsage
  • usagePercent
  • resetInSec

slkiser avatar Jun 15 '26 17:06 slkiser

Nop, needs to update the parser

<div data-slot="usage"><!--$-->
        <div data-slot="usage-item">
            <div data-slot="usage-header"><span data-slot="usage-label">Rolling Usage</span><span
                    data-slot="usage-value"><!--$-->1<!--/-->%</span></div>
            <div data-slot="progress">
                <div data-slot="progress-bar" style="width: 1%;"></div>
            </div><span data-slot="reset-time"><!--$-->Resets in<!--/--> <!--$-->1 hour 56 minutes<!--/--></span>
        </div><!--/--><!--$-->
        <div data-slot="usage-item">
            <div data-slot="usage-header"><span data-slot="usage-label">Weekly Usage</span><span
                    data-slot="usage-value"><!--$-->1<!--/-->%</span></div>
            <div data-slot="progress">
                <div data-slot="progress-bar" style="width: 1%;"></div>
            </div><span data-slot="reset-time"><!--$-->Resets in<!--/--> <!--$-->6 days 2 hours<!--/--></span>
        </div><!--/--><!--$-->
        <div data-slot="usage-item">
            <div data-slot="usage-header"><span data-slot="usage-label">Monthly Usage</span><span
                    data-slot="usage-value"><!--$-->0<!--/-->%</span></div>
            <div data-slot="progress">
                <div data-slot="progress-bar" style="width: 0%;"></div>
            </div><span data-slot="reset-time"><!--$-->Resets in<!--/--> <!--$-->26 days 17 hours<!--/--></span>
        </div><!--/-->
    </div>

valentimarco avatar Jun 15 '26 21:06 valentimarco

This issue has been inactive for 23 days. It will be closed in 7 days if there is no further activity.

github-actions[bot] avatar Jul 09 '26 11:07 github-actions[bot]

https://github.com/anomalyco/opencode/pull/16513 got merged into OpenCode dev.

slkiser avatar Aug 11 '26 21:08 slkiser

Can finally close, API in v4.8.0

slkiser avatar Aug 12 '26 10:08 slkiser