@opencode/protocol 0.0.0-dev-21775 → 0.0.0-dev-21776

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/api.d.ts CHANGED
@@ -27,6 +27,7 @@ import { Authorization } from "./middleware/authorization.js";
27
27
  import { makeLocationGroup } from "./groups/location.js";
28
28
  import { IntegrationGroup } from "./groups/integration.js";
29
29
  import { WebSearchGroup } from "./groups/websearch.js";
30
+ import { UsageGroup } from "./groups/usage.js";
30
31
  import { makeMcpGroup } from "./groups/mcp.js";
31
32
  import { CredentialGroup } from "./groups/credential.js";
32
33
  import { ProjectGroup } from "./groups/project.js";
@@ -34,7 +35,7 @@ import { WorktreeGroup } from "./groups/worktree.js";
34
35
  import { VcsGroup } from "./groups/vcs.js";
35
36
  import { MigrationGroup } from "./groups/migration.js";
36
37
  import { ConfigGroup } from "./groups/config.js";
37
- type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof WebSearchGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof RpcGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
38
+ type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof WebSearchGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof UsageGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof RpcGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
38
39
  type PtyGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makePtyGroup<LocationId, LocationService>>;
39
40
  type McpGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makeMcpGroup<LocationId, LocationService>>;
40
41
  type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService> = ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService, FormLocationId, FormLocationService>> | typeof MessageGroup;
package/dist/api.js CHANGED
@@ -26,6 +26,7 @@ import { Authorization } from "./middleware/authorization.js";
26
26
  import { makeLocationGroup } from "./groups/location.js";
27
27
  import { IntegrationGroup } from "./groups/integration.js";
28
28
  import { WebSearchGroup } from "./groups/websearch.js";
29
+ import { UsageGroup } from "./groups/usage.js";
29
30
  import { makeMcpGroup } from "./groups/mcp.js";
30
31
  import { CredentialGroup } from "./groups/credential.js";
31
32
  import { ProjectGroup } from "./groups/project.js";
@@ -65,6 +66,7 @@ const makeApiFromGroup = (eventGroup, locationMiddleware, formLocationMiddleware
65
66
  .add(DebugGroup)
66
67
  .add(MigrationGroup)
67
68
  .add(WebSearchGroup.middleware(locationMiddleware))
69
+ .add(UsageGroup.middleware(locationMiddleware))
68
70
  .add(ConfigGroup.middleware(locationMiddleware))
69
71
  .annotateMerge(OpenApi.annotations({
70
72
  title: "opencode HttpApi",
package/dist/client.d.ts CHANGED
@@ -40,6 +40,7 @@ export declare const groupNames: {
40
40
  readonly "server.provider": "provider";
41
41
  readonly "server.integration": "integration";
42
42
  readonly "server.websearch": "websearch";
43
+ readonly "server.usage": "usage";
43
44
  readonly "server.credential": "credential";
44
45
  readonly "server.form": "form";
45
46
  readonly "server.permission": "permission";
package/dist/client.js CHANGED
@@ -27,6 +27,7 @@ export const groupNames = {
27
27
  "server.provider": "provider",
28
28
  "server.integration": "integration",
29
29
  "server.websearch": "websearch",
30
+ "server.usage": "usage",
30
31
  "server.credential": "credential",
31
32
  "server.form": "form",
32
33
  "server.permission": "permission",
@@ -0,0 +1,95 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
3
+ import { ServiceUnavailableError } from "../errors.js";
4
+ export declare const UsageGroup: HttpApiGroup.HttpApiGroup<"server.usage", HttpApiEndpoint.HttpApiEndpoint<"usage.limits", "GET", "/api/experimental/usage/limits", never, Schema.toCodecStringTree<Schema.Struct<{
5
+ readonly location: Schema.optional<Schema.Struct<{
6
+ readonly directory: Schema.optional<Schema.String>;
7
+ }>>;
8
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
9
+ readonly location: Schema.Struct<{
10
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
11
+ }>;
12
+ readonly data: Schema.NullOr<Schema.Struct<{
13
+ readonly workspace: Schema.Struct<{
14
+ readonly id: Schema.String;
15
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
16
+ readonly usageURL: Schema.String;
17
+ }>;
18
+ readonly go: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
19
+ readonly rolling: Schema.Struct<{
20
+ readonly percent: Schema.Finite;
21
+ readonly limited: Schema.Boolean;
22
+ readonly resetsAt: Schema.Finite;
23
+ }>;
24
+ readonly weekly: Schema.Struct<{
25
+ readonly percent: Schema.Finite;
26
+ readonly limited: Schema.Boolean;
27
+ readonly resetsAt: Schema.Finite;
28
+ }>;
29
+ readonly monthly: Schema.Struct<{
30
+ readonly percent: Schema.Finite;
31
+ readonly limited: Schema.Boolean;
32
+ readonly resetsAt: Schema.Finite;
33
+ }>;
34
+ }>>>, Schema.optionalKey<Schema.Struct<{
35
+ readonly rolling: Schema.Struct<{
36
+ readonly percent: Schema.Finite;
37
+ readonly limited: Schema.Boolean;
38
+ readonly resetsAt: Schema.Finite;
39
+ }>;
40
+ readonly weekly: Schema.Struct<{
41
+ readonly percent: Schema.Finite;
42
+ readonly limited: Schema.Boolean;
43
+ readonly resetsAt: Schema.Finite;
44
+ }>;
45
+ readonly monthly: Schema.Struct<{
46
+ readonly percent: Schema.Finite;
47
+ readonly limited: Schema.Boolean;
48
+ readonly resetsAt: Schema.Finite;
49
+ }>;
50
+ }>>, never, never>;
51
+ readonly budgets: Schema.$Array<Schema.Struct<{
52
+ readonly id: Schema.String;
53
+ readonly limit: Schema.brand<Schema.Finite, "Money.USD"> & {
54
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
55
+ };
56
+ readonly spent: Schema.brand<Schema.Finite, "Money.USD"> & {
57
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
58
+ };
59
+ readonly scope: Schema.Literals<readonly ["each", "combined"]>;
60
+ readonly per: Schema.Literals<readonly ["set", "model"]>;
61
+ readonly coverage: Schema.Literals<readonly ["all", "models"]>;
62
+ readonly models: Schema.$Array<Schema.Struct<{
63
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
64
+ opencode: string & import("effect/Brand").Brand<"Provider.ID">;
65
+ anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
66
+ openai: string & import("effect/Brand").Brand<"Provider.ID">;
67
+ google: string & import("effect/Brand").Brand<"Provider.ID">;
68
+ googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
69
+ githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
70
+ amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
71
+ azure: string & import("effect/Brand").Brand<"Provider.ID">;
72
+ openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
73
+ mistral: string & import("effect/Brand").Brand<"Provider.ID">;
74
+ gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
75
+ };
76
+ readonly modelID: Schema.brand<Schema.String, "Model.ID">;
77
+ readonly name: Schema.String;
78
+ readonly spent: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
79
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
80
+ }>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
81
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
82
+ }>, never, never>;
83
+ }>>;
84
+ readonly vendors: Schema.$Array<Schema.String>;
85
+ readonly inputPriceAtLeast: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
86
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
87
+ }>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
88
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
89
+ }>, never, never>;
90
+ readonly picked: Schema.Boolean;
91
+ readonly shared: Schema.Boolean;
92
+ readonly resetsAt: Schema.Finite;
93
+ }>>;
94
+ }>>;
95
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never>, false>;
@@ -0,0 +1,22 @@
1
+ import { Location } from "@opencode/schema/location";
2
+ import { UsageLimits } from "@opencode/schema/usage-limits";
3
+ import { Schema } from "effect";
4
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
5
+ import { ServiceUnavailableError } from "../errors.js";
6
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
7
+ export const UsageGroup = HttpApiGroup.make("server.usage")
8
+ .add(HttpApiEndpoint.get("usage.limits", "/api/experimental/usage/limits", {
9
+ query: LocationQuery,
10
+ success: Location.response(Schema.NullOr(UsageLimits.Info)),
11
+ error: ServiceUnavailableError,
12
+ })
13
+ .annotateMerge(locationQueryOpenApi)
14
+ .annotateMerge(OpenApi.annotations({
15
+ identifier: "experimental.usage.limits",
16
+ summary: "Get usage limits",
17
+ description: "Return the OpenCode Go allowance and Console budgets of the OpenCode Console workspace the location is signed in to, or null when it isn't signed in.",
18
+ })))
19
+ .annotateMerge(OpenApi.annotations({
20
+ title: "usage",
21
+ description: "Experimental usage limit routes.",
22
+ }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/protocol",
4
- "version": "0.0.0-dev-21775",
4
+ "version": "0.0.0-dev-21776",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "typecheck:tsc": "tsc --noEmit"
35
35
  },
36
36
  "dependencies": {
37
- "@opencode/schema": "0.0.0-dev-21775",
37
+ "@opencode/schema": "0.0.0-dev-21776",
38
38
  "effect": "4.0.1"
39
39
  },
40
40
  "devDependencies": {