@route_33/opencode 0.4.7-rc.6 → 0.4.7-rc.8

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.
@@ -1,6 +1,41 @@
1
1
  // src/v2-entry/create-route33-v2-plugin/create-route33-v2-plugin.ts
2
2
  import { Integration as Integration2, Plugin } from "@opencode/plugin";
3
3
 
4
+ // src/auth/authorization-url-stash/authorization-url-stash.ts
5
+ var FALLBACK_URL = "https://route33.ai";
6
+ var SIGN_IN_INSTRUCTIONS = "Open the Route 33 sign-in link \u2014 your browser will finish at a confirmation page.";
7
+ var FINISHING_INSTRUCTIONS = "Finishing Route 33 setup\u2026";
8
+ var URL_WAIT_BUDGET_MS = 3e4;
9
+ var createAuthorizationUrlStash = () => {
10
+ let resolveUrl;
11
+ const nextUrl = new Promise((resolve2) => {
12
+ resolveUrl = resolve2;
13
+ });
14
+ const browserRunner = (url) => {
15
+ resolveUrl?.(url);
16
+ return Promise.resolve();
17
+ };
18
+ const urlForConnect = async (callback) => {
19
+ let decide;
20
+ const decided = new Promise((resolve2) => {
21
+ decide = resolve2;
22
+ });
23
+ const timer = setTimeout(() => {
24
+ decide({ instructions: SIGN_IN_INSTRUCTIONS, url: FALLBACK_URL });
25
+ }, URL_WAIT_BUDGET_MS);
26
+ void nextUrl.then((url) => {
27
+ clearTimeout(timer);
28
+ decide({ instructions: SIGN_IN_INSTRUCTIONS, url: url.toString() });
29
+ });
30
+ void Promise.resolve(callback).catch(() => void 0).then(() => {
31
+ clearTimeout(timer);
32
+ decide({ instructions: FINISHING_INSTRUCTIONS, url: FALLBACK_URL });
33
+ });
34
+ return decided;
35
+ };
36
+ return { browserRunner, urlForConnect };
37
+ };
38
+
4
39
  // src/cli/read-env-base-url/read-env-base-url.ts
5
40
  var readEnvBaseUrl = (env = process.env) => {
6
41
  const value = env["ROUTE33_BASE_URL"]?.trim();
@@ -3791,41 +3826,6 @@ var buildProductionRuntimeOptions = (input) => ({
3791
3826
  ...input.tokenStore === void 0 ? {} : { tokenStore: input.tokenStore }
3792
3827
  });
3793
3828
 
3794
- // src/v2-entry/authorization-url-stash/authorization-url-stash.ts
3795
- var FALLBACK_URL = "https://route33.ai";
3796
- var SIGN_IN_INSTRUCTIONS = "Open the Route 33 sign-in link \u2014 your browser will finish at a confirmation page.";
3797
- var FINISHING_INSTRUCTIONS = "Finishing Route 33 setup\u2026";
3798
- var URL_WAIT_BUDGET_MS = 3e4;
3799
- var createAuthorizationUrlStash = () => {
3800
- let resolveUrl;
3801
- const nextUrl = new Promise((resolve2) => {
3802
- resolveUrl = resolve2;
3803
- });
3804
- const browserRunner = (url) => {
3805
- resolveUrl?.(url);
3806
- return Promise.resolve();
3807
- };
3808
- const urlForConnect = async (callback) => {
3809
- let decide;
3810
- const decided = new Promise((resolve2) => {
3811
- decide = resolve2;
3812
- });
3813
- const timer = setTimeout(() => {
3814
- decide({ instructions: SIGN_IN_INSTRUCTIONS, url: FALLBACK_URL });
3815
- }, URL_WAIT_BUDGET_MS);
3816
- void nextUrl.then((url) => {
3817
- clearTimeout(timer);
3818
- decide({ instructions: SIGN_IN_INSTRUCTIONS, url: url.toString() });
3819
- });
3820
- void Promise.resolve(callback).catch(() => void 0).then(() => {
3821
- clearTimeout(timer);
3822
- decide({ instructions: FINISHING_INSTRUCTIONS, url: FALLBACK_URL });
3823
- });
3824
- return decided;
3825
- };
3826
- return { browserRunner, urlForConnect };
3827
- };
3828
-
3829
3829
  // src/v2-entry/connect-copy/connect-copy.ts
3830
3830
  var CONNECT_COPY = {
3831
3831
  failFastClientId: "This Route 33 build has no OAuth client id. Reinstall it from the opencode-dist ref, or set ROUTE33_CLIENT_ID and restart OpenCode.",
@@ -4006,12 +4006,10 @@ var hostTokenStore = (options) => ({
4006
4006
  // src/v2-entry/parse-r33-subcommand/parse-r33-subcommand.ts
4007
4007
  var SUBCOMMANDS = ["inspect", "rotate", "reset"];
4008
4008
  var parseR33Subcommand = (promptText) => {
4009
- const [invocation, argument] = promptText.trim().split(/\s+/u);
4010
- const name = invocation?.replace(/^\/+/u, "").split(":")[0] ?? "";
4011
- if (name !== "r33") {
4012
- return "help";
4013
- }
4014
- if (argument === void 0) {
4009
+ const [first = "", ...rest] = promptText.trim().split(/\s+/u).filter(Boolean);
4010
+ const name = first.replace(/^\/+/u, "").split(":")[0] ?? "";
4011
+ const argument = name === "r33" ? rest[0] : first;
4012
+ if (argument === void 0 || argument === "") {
4015
4013
  return "inspect";
4016
4014
  }
4017
4015
  return SUBCOMMANDS.includes(argument) ? argument : "help";
@@ -4041,6 +4039,20 @@ var executeR33Command = async (input) => {
4041
4039
  }
4042
4040
  };
4043
4041
 
4042
+ // src/v2-entry/v2-unattributed-model-gate/v2-unattributed-model-gate.ts
4043
+ var GATE_COPY = "Route 33 needs a budget for this folder first \u2014 finish the setup dialog in the TUI, or run /connect, choose Route 33, and follow the steps.";
4044
+ var createV2UnattributedModelGate = (deps) => async (input) => {
4045
+ if (input.model.providerID !== "route_33") return;
4046
+ const session = await deps.session.get({ sessionID: input.sessionID });
4047
+ const directory = session?.location.directory ?? deps.fallbackDirectory;
4048
+ const state = {
4049
+ directory,
4050
+ outsideWorktree: "return-undefined"
4051
+ };
4052
+ if (readAttribution(state) !== void 0) return;
4053
+ throw new Error(GATE_COPY);
4054
+ };
4055
+
4044
4056
  // src/v2-entry/workspace-key-request-hook/workspace-key-request-hook.ts
4045
4057
  var createWorkspaceKeyHook = (deps) => async (input) => {
4046
4058
  const target = new URL(input.request.url);
@@ -4191,6 +4203,14 @@ var createRoute33V2Plugin = (options = {}) => {
4191
4203
  session: context.session
4192
4204
  })
4193
4205
  );
4206
+ const modelGate = await context.session.hook(
4207
+ "model.request",
4208
+ createV2UnattributedModelGate({
4209
+ fallbackDirectory: context.location.directory,
4210
+ session: context.session
4211
+ }),
4212
+ { providerID: "route_33" }
4213
+ );
4194
4214
  const bootstrapFromRefresh = async () => {
4195
4215
  if (runtime === void 0) {
4196
4216
  return;
@@ -4223,7 +4243,8 @@ var createRoute33V2Plugin = (options = {}) => {
4223
4243
  commandTransform.dispose(),
4224
4244
  integrationTransform.dispose(),
4225
4245
  providerTransform.dispose(),
4226
- sessionHook.dispose()
4246
+ sessionHook.dispose(),
4247
+ modelGate.dispose()
4227
4248
  ]);
4228
4249
  };
4229
4250
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@route_33/opencode",
3
- "version": "0.4.7-rc.6",
3
+ "version": "0.4.7-rc.8",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,8 +42,8 @@
42
42
  "eslint": "10.13.0",
43
43
  "typescript": "6.0.3",
44
44
  "vitest": "5.0.5",
45
- "@cronos-ai-lab/typescript-config": "0.1.2",
46
- "@cronos-ai-lab/eslint-config": "0.1.2"
45
+ "@cronos-ai-lab/eslint-config": "0.1.2",
46
+ "@cronos-ai-lab/typescript-config": "0.1.2"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "esbuild src/index.ts src/v2-entry/index.ts src/tui-entry/index.ts src/cli/production-smoke/production-smoke.ts --bundle --format=esm --platform=node --packages=external --outbase=src --outdir=dist --alias:@opencode-ai/plugin-v2=@opencode/plugin --define:__ROUTE33_DEFAULT_CLIENT_ID__=\\\"${ROUTE33_DEFAULT_CLIENT_ID:-}\\\"",