@r-33/opencode 0.4.7-rc.24 → 0.4.7-rc.25
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/index.js +7 -4
- package/dist/tui-entry/index.js +200 -111
- package/dist/v2-entry/index.js +56 -128
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2588,7 +2588,7 @@ var createLeaseInstallationFactory = (options) => {
|
|
|
2588
2588
|
return existing;
|
|
2589
2589
|
}
|
|
2590
2590
|
const installation = {
|
|
2591
|
-
keyName: `
|
|
2591
|
+
keyName: `route33_lease_${scopeId}`,
|
|
2592
2592
|
secretStore: options.createSecretStore(scopeId),
|
|
2593
2593
|
...options.createStateStore === void 0 ? {} : { stateStore: options.createStateStore(scopeId) },
|
|
2594
2594
|
state: LeaseState.restore(void 0)
|
|
@@ -2906,11 +2906,14 @@ var Route33Runtime = class {
|
|
|
2906
2906
|
* member-visible project listing, organisation names stitched from the
|
|
2907
2907
|
* login's own memberships. Orgs the login merely administers carry no
|
|
2908
2908
|
* budget row and drop out — the picker never offers a project whose
|
|
2909
|
-
* keys the login cannot create.
|
|
2909
|
+
* keys the login cannot create. A `allowBrowser: false` policy makes
|
|
2910
|
+
* the call non-blocking: a dead session rejects instead of opening a
|
|
2911
|
+
* browser, so the picker's form registration never stalls a boot.
|
|
2912
|
+
* @param policy - Whether a dead session may open a browser login.
|
|
2910
2913
|
* @returns Mintable projects with organisation context for the picker.
|
|
2911
2914
|
*/
|
|
2912
|
-
async listMintableProjects() {
|
|
2913
|
-
const credential = await this.#session.credential();
|
|
2915
|
+
async listMintableProjects(policy = {}) {
|
|
2916
|
+
const credential = await this.#session.credential(policy);
|
|
2914
2917
|
const subject = this.#subject(credential);
|
|
2915
2918
|
const client = this.#client();
|
|
2916
2919
|
const [budgets, memberships] = await Promise.all([
|
package/dist/tui-entry/index.js
CHANGED
|
@@ -13,70 +13,6 @@ var __export = (target, all) => {
|
|
|
13
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
// src/cli/e2e-bin/is-executable/is-executable.ts
|
|
17
|
-
var init_is_executable = __esm({
|
|
18
|
-
"src/cli/e2e-bin/is-executable/is-executable.ts"() {
|
|
19
|
-
"use strict";
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// src/cli/e2e-bin/is-executable/index.ts
|
|
24
|
-
var init_is_executable2 = __esm({
|
|
25
|
-
"src/cli/e2e-bin/is-executable/index.ts"() {
|
|
26
|
-
"use strict";
|
|
27
|
-
init_is_executable();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// src/cli/e2e-bin/e2e-bin.ts
|
|
32
|
-
var init_e2e_bin = __esm({
|
|
33
|
-
"src/cli/e2e-bin/e2e-bin.ts"() {
|
|
34
|
-
"use strict";
|
|
35
|
-
init_is_executable2();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// src/cli/e2e-bin/find-host-binary/find-host-binary.ts
|
|
40
|
-
var init_find_host_binary = __esm({
|
|
41
|
-
"src/cli/e2e-bin/find-host-binary/find-host-binary.ts"() {
|
|
42
|
-
"use strict";
|
|
43
|
-
init_e2e_bin();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// src/cli/e2e-bin/find-host-binary/index.ts
|
|
48
|
-
var init_find_host_binary2 = __esm({
|
|
49
|
-
"src/cli/e2e-bin/find-host-binary/index.ts"() {
|
|
50
|
-
"use strict";
|
|
51
|
-
init_find_host_binary();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// src/cli/e2e-bin/parent-host-env/parent-host-env.ts
|
|
56
|
-
var init_parent_host_env = __esm({
|
|
57
|
-
"src/cli/e2e-bin/parent-host-env/parent-host-env.ts"() {
|
|
58
|
-
"use strict";
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// src/cli/e2e-bin/parent-host-env/index.ts
|
|
63
|
-
var init_parent_host_env2 = __esm({
|
|
64
|
-
"src/cli/e2e-bin/parent-host-env/index.ts"() {
|
|
65
|
-
"use strict";
|
|
66
|
-
init_parent_host_env();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// src/cli/e2e-bin/index.ts
|
|
71
|
-
var init_e2e_bin2 = __esm({
|
|
72
|
-
"src/cli/e2e-bin/index.ts"() {
|
|
73
|
-
"use strict";
|
|
74
|
-
init_e2e_bin();
|
|
75
|
-
init_find_host_binary2();
|
|
76
|
-
init_parent_host_env2();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
16
|
// src/cli/read-env-base-url/read-env-base-url.ts
|
|
81
17
|
var readEnvBaseUrl;
|
|
82
18
|
var init_read_env_base_url = __esm({
|
|
@@ -523,21 +459,6 @@ var init_read_env_strict2 = __esm({
|
|
|
523
459
|
}
|
|
524
460
|
});
|
|
525
461
|
|
|
526
|
-
// src/cli/read-e2e-dev-env/read-e2e-dev-env.ts
|
|
527
|
-
var init_read_e2e_dev_env = __esm({
|
|
528
|
-
"src/cli/read-e2e-dev-env/read-e2e-dev-env.ts"() {
|
|
529
|
-
"use strict";
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
// src/cli/read-e2e-dev-env/index.ts
|
|
534
|
-
var init_read_e2e_dev_env2 = __esm({
|
|
535
|
-
"src/cli/read-e2e-dev-env/index.ts"() {
|
|
536
|
-
"use strict";
|
|
537
|
-
init_read_e2e_dev_env();
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
|
|
541
462
|
// src/cli/resolve-v1-secret-store-directory/resolve-v1-secret-store-directory.ts
|
|
542
463
|
import * as os2 from "node:os";
|
|
543
464
|
import * as path2 from "node:path";
|
|
@@ -576,7 +497,6 @@ var init_resolve_v1_secret_store_directory2 = __esm({
|
|
|
576
497
|
var init_cli = __esm({
|
|
577
498
|
"src/cli/index.ts"() {
|
|
578
499
|
"use strict";
|
|
579
|
-
init_e2e_bin2();
|
|
580
500
|
init_read_env_base_url2();
|
|
581
501
|
init_read_env_api_base2();
|
|
582
502
|
init_read_env_auth_issuer2();
|
|
@@ -588,7 +508,6 @@ var init_cli = __esm({
|
|
|
588
508
|
init_read_env_disable_id_shim2();
|
|
589
509
|
init_read_env_discovery2();
|
|
590
510
|
init_read_env_strict2();
|
|
591
|
-
init_read_e2e_dev_env2();
|
|
592
511
|
init_resolve_v1_secret_store_directory2();
|
|
593
512
|
}
|
|
594
513
|
});
|
|
@@ -4091,10 +4010,33 @@ var init_file_secret_store2 = __esm({
|
|
|
4091
4010
|
});
|
|
4092
4011
|
|
|
4093
4012
|
// src/key-lease/host-storage-secret-store/host-storage-secret-store.ts
|
|
4013
|
+
var HostStorageSecretStore;
|
|
4094
4014
|
var init_host_storage_secret_store = __esm({
|
|
4095
4015
|
"src/key-lease/host-storage-secret-store/host-storage-secret-store.ts"() {
|
|
4096
4016
|
"use strict";
|
|
4097
4017
|
init_adapters();
|
|
4018
|
+
HostStorageSecretStore = class {
|
|
4019
|
+
#key;
|
|
4020
|
+
#storage;
|
|
4021
|
+
constructor(options) {
|
|
4022
|
+
this.#key = options.key;
|
|
4023
|
+
this.#storage = options.storage;
|
|
4024
|
+
}
|
|
4025
|
+
/** Reads and parses the scoped gateway credential.
|
|
4026
|
+
* @returns The persisted credential, when present.
|
|
4027
|
+
*/
|
|
4028
|
+
async get() {
|
|
4029
|
+
const value = await this.#storage.get(this.#key);
|
|
4030
|
+
return value === void 0 ? void 0 : parseGatewayKey(value);
|
|
4031
|
+
}
|
|
4032
|
+
/** Writes the scoped gateway credential only through host-owned storage.
|
|
4033
|
+
* @param key - The credential to persist, or undefined to remove it.
|
|
4034
|
+
* @returns A promise that settles after the host write or removal.
|
|
4035
|
+
*/
|
|
4036
|
+
set(key) {
|
|
4037
|
+
return key === void 0 ? this.#storage.remove(this.#key) : this.#storage.set(this.#key, key.value);
|
|
4038
|
+
}
|
|
4039
|
+
};
|
|
4098
4040
|
}
|
|
4099
4041
|
});
|
|
4100
4042
|
|
|
@@ -5288,7 +5230,7 @@ var init_lease_installation_factory = __esm({
|
|
|
5288
5230
|
return existing;
|
|
5289
5231
|
}
|
|
5290
5232
|
const installation = {
|
|
5291
|
-
keyName: `
|
|
5233
|
+
keyName: `route33_lease_${scopeId}`,
|
|
5292
5234
|
secretStore: options.createSecretStore(scopeId),
|
|
5293
5235
|
...options.createStateStore === void 0 ? {} : { stateStore: options.createStateStore(scopeId) },
|
|
5294
5236
|
state: LeaseState.restore(void 0)
|
|
@@ -5877,11 +5819,14 @@ var init_route33_runtime = __esm({
|
|
|
5877
5819
|
* member-visible project listing, organisation names stitched from the
|
|
5878
5820
|
* login's own memberships. Orgs the login merely administers carry no
|
|
5879
5821
|
* budget row and drop out — the picker never offers a project whose
|
|
5880
|
-
* keys the login cannot create.
|
|
5822
|
+
* keys the login cannot create. A `allowBrowser: false` policy makes
|
|
5823
|
+
* the call non-blocking: a dead session rejects instead of opening a
|
|
5824
|
+
* browser, so the picker's form registration never stalls a boot.
|
|
5825
|
+
* @param policy - Whether a dead session may open a browser login.
|
|
5881
5826
|
* @returns Mintable projects with organisation context for the picker.
|
|
5882
5827
|
*/
|
|
5883
|
-
async listMintableProjects() {
|
|
5884
|
-
const credential = await this.#session.credential();
|
|
5828
|
+
async listMintableProjects(policy = {}) {
|
|
5829
|
+
const credential = await this.#session.credential(policy);
|
|
5885
5830
|
const subject = this.#subject(credential);
|
|
5886
5831
|
const client = this.#client();
|
|
5887
5832
|
const [budgets, memberships] = await Promise.all([
|
|
@@ -7463,6 +7408,13 @@ var answerPass = async (deps) => {
|
|
|
7463
7408
|
});
|
|
7464
7409
|
return;
|
|
7465
7410
|
}
|
|
7411
|
+
const openUrl = () => {
|
|
7412
|
+
try {
|
|
7413
|
+
void deps.openSystemBrowser(new URL(second.data.url)).catch(() => void 0);
|
|
7414
|
+
} catch {
|
|
7415
|
+
}
|
|
7416
|
+
};
|
|
7417
|
+
openUrl();
|
|
7466
7418
|
const settled = await deps.pollTerminal(second.data.attemptID);
|
|
7467
7419
|
if (settled.kind !== "complete") {
|
|
7468
7420
|
deps.toast(v2OutcomeCopy(settled, V2_CONNECT_COPY.setupIncomplete));
|
|
@@ -7472,6 +7424,9 @@ var answerPass = async (deps) => {
|
|
|
7472
7424
|
deps.toast({ message: V2_CONNECT_COPY.success, variant: "success" });
|
|
7473
7425
|
};
|
|
7474
7426
|
|
|
7427
|
+
// src/tui-entry/v2-budget-picker/v2-budget-picker.ts
|
|
7428
|
+
import { openSystemBrowser } from "@r-33/auth-browser";
|
|
7429
|
+
|
|
7475
7430
|
// src/tui-entry/v2-integration-surface/v2-integration-surface.ts
|
|
7476
7431
|
var v2IntegrationSurface = (context) => context.client?.integration ?? context.client?.api?.integration;
|
|
7477
7432
|
|
|
@@ -7556,6 +7511,7 @@ var v2BudgetPicker = async (deps) => {
|
|
|
7556
7511
|
}
|
|
7557
7512
|
await answerPass({
|
|
7558
7513
|
connect: deps.connect,
|
|
7514
|
+
openSystemBrowser: deps.openSystemBrowser ?? openSystemBrowser,
|
|
7559
7515
|
dialog: deps.dialog,
|
|
7560
7516
|
extras,
|
|
7561
7517
|
form: deps.form,
|
|
@@ -7733,6 +7689,7 @@ var v2GuidedConnect = async (deps) => {
|
|
|
7733
7689
|
dialog,
|
|
7734
7690
|
form,
|
|
7735
7691
|
locationInput,
|
|
7692
|
+
...deps.openSystemBrowser === void 0 ? {} : { openSystemBrowser: deps.openSystemBrowser },
|
|
7736
7693
|
pollTerminal,
|
|
7737
7694
|
toast,
|
|
7738
7695
|
unattributed
|
|
@@ -7795,24 +7752,26 @@ var v2Autoconnect = async (context, options = {}) => {
|
|
|
7795
7752
|
}
|
|
7796
7753
|
await v2GuidedConnect({
|
|
7797
7754
|
context,
|
|
7755
|
+
...options.openSystemBrowser === void 0 ? {} : { openSystemBrowser: options.openSystemBrowser },
|
|
7798
7756
|
superseded: options.superseded,
|
|
7799
7757
|
unattributed
|
|
7800
7758
|
});
|
|
7801
7759
|
};
|
|
7802
7760
|
|
|
7803
7761
|
// src/tui-entry/show-r33-menu/run-action/run-action.ts
|
|
7804
|
-
var runR33MenuAction = (context, action) => {
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7762
|
+
var runR33MenuAction = async (context, action, deps) => {
|
|
7763
|
+
try {
|
|
7764
|
+
const reply = await executeR33Command({
|
|
7765
|
+
handlers: deps.handlers(),
|
|
7766
|
+
promptText: `/r33 ${action}`
|
|
7767
|
+
});
|
|
7768
|
+
context.ui.toast.show({ message: reply, variant: "info" });
|
|
7769
|
+
} catch (error) {
|
|
7809
7770
|
context.ui.toast.show({
|
|
7810
|
-
message:
|
|
7771
|
+
message: error instanceof Error ? error.message : String(error),
|
|
7811
7772
|
variant: "error"
|
|
7812
7773
|
});
|
|
7813
|
-
return;
|
|
7814
7774
|
}
|
|
7815
|
-
context.keymap.dispatch(serverR33.id, `r33 ${action}`);
|
|
7816
7775
|
};
|
|
7817
7776
|
|
|
7818
7777
|
// src/tui-entry/show-r33-menu/show-r33-menu.ts
|
|
@@ -7834,7 +7793,7 @@ var menuOptions2 = [
|
|
|
7834
7793
|
value: "logout"
|
|
7835
7794
|
}
|
|
7836
7795
|
];
|
|
7837
|
-
var showR33Menu = async (context) => {
|
|
7796
|
+
var showR33Menu = async (context, deps) => {
|
|
7838
7797
|
const selection = await context.ui.dialog.select({
|
|
7839
7798
|
title: "Route 33 \u2014 choose an action",
|
|
7840
7799
|
options: menuOptions2
|
|
@@ -7848,10 +7807,12 @@ var showR33Menu = async (context) => {
|
|
|
7848
7807
|
outsideWorktree: "return-undefined"
|
|
7849
7808
|
});
|
|
7850
7809
|
}
|
|
7851
|
-
await v2Autoconnect(context
|
|
7810
|
+
await v2Autoconnect(context, {
|
|
7811
|
+
...deps.openSystemBrowser === void 0 ? {} : { openSystemBrowser: deps.openSystemBrowser }
|
|
7812
|
+
});
|
|
7852
7813
|
return;
|
|
7853
7814
|
}
|
|
7854
|
-
runR33MenuAction(context, selection);
|
|
7815
|
+
await runR33MenuAction(context, selection, deps);
|
|
7855
7816
|
};
|
|
7856
7817
|
|
|
7857
7818
|
// src/tui-entry/v2-route33-model-candidate/v2-route33-model-candidate.ts
|
|
@@ -7909,12 +7870,14 @@ var v2AutoSelectModel = async ({
|
|
|
7909
7870
|
// src/tui-entry/v2-boot-matrix/v2-boot-matrix.ts
|
|
7910
7871
|
var v2BootMatrix = async ({
|
|
7911
7872
|
probe,
|
|
7873
|
+
assumedAlive = false,
|
|
7912
7874
|
attributed,
|
|
7913
7875
|
globalFallback,
|
|
7914
7876
|
wizard
|
|
7915
7877
|
}) => {
|
|
7916
|
-
if (await probe() === "dead") {
|
|
7917
|
-
|
|
7878
|
+
if (!assumedAlive && await probe() === "dead") {
|
|
7879
|
+
await wizard();
|
|
7880
|
+
return { kind: "wizard-settled" };
|
|
7918
7881
|
}
|
|
7919
7882
|
if (attributed()) {
|
|
7920
7883
|
return { kind: "silent" };
|
|
@@ -7926,6 +7889,16 @@ var v2BootMatrix = async ({
|
|
|
7926
7889
|
return { kind: "wizard-settled" };
|
|
7927
7890
|
};
|
|
7928
7891
|
|
|
7892
|
+
// src/tui-entry/v2-boot-reentry/v2-boot-reentry.ts
|
|
7893
|
+
var registerV2BootReentry = (deps) => {
|
|
7894
|
+
deps.listen?.((event) => {
|
|
7895
|
+
if (!event.details.type.includes("integration")) return;
|
|
7896
|
+
if (deps.superseded()) return;
|
|
7897
|
+
if (!deps.pending()) return;
|
|
7898
|
+
void deps.start().catch(() => void 0);
|
|
7899
|
+
});
|
|
7900
|
+
};
|
|
7901
|
+
|
|
7929
7902
|
// src/v2-entry/connect-copy/connect-copy.ts
|
|
7930
7903
|
var CONNECT_COPY = {
|
|
7931
7904
|
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.",
|
|
@@ -7936,7 +7909,7 @@ var CONNECT_COPY = {
|
|
|
7936
7909
|
|
|
7937
7910
|
// src/v2-entry/resolve-host-credential/resolve-host-credential.ts
|
|
7938
7911
|
init_config();
|
|
7939
|
-
var NO_USABLE_LEASE_MESSAGE = "Route 33
|
|
7912
|
+
var NO_USABLE_LEASE_MESSAGE = "Signed in to Route 33 \u2713. One more step: this folder has no gateway key yet \u2014 pick its budget to finish setup.";
|
|
7940
7913
|
|
|
7941
7914
|
// src/tui-entry/v2-session-probe/v2-session-probe.ts
|
|
7942
7915
|
var v2SessionProbe = async ({
|
|
@@ -8020,12 +7993,12 @@ var v2SetupLock = (deps) => {
|
|
|
8020
7993
|
});
|
|
8021
7994
|
}
|
|
8022
7995
|
let running = false;
|
|
8023
|
-
const settle = async () => {
|
|
7996
|
+
const settle = async (options) => {
|
|
8024
7997
|
if (running) return;
|
|
8025
7998
|
running = true;
|
|
8026
7999
|
try {
|
|
8027
8000
|
if (deps.pending()) {
|
|
8028
|
-
await deps.run();
|
|
8001
|
+
await deps.run(options);
|
|
8029
8002
|
}
|
|
8030
8003
|
} finally {
|
|
8031
8004
|
running = false;
|
|
@@ -8036,6 +8009,115 @@ var v2SetupLock = (deps) => {
|
|
|
8036
8009
|
return { start: settle };
|
|
8037
8010
|
};
|
|
8038
8011
|
|
|
8012
|
+
// src/tui-entry/v2-tui-runtime/v2-tui-runtime.ts
|
|
8013
|
+
init_cli();
|
|
8014
|
+
init_host_storage_secret_store2();
|
|
8015
|
+
init_key_lease();
|
|
8016
|
+
init_requested_client_id2();
|
|
8017
|
+
init_route33_runtime2();
|
|
8018
|
+
init_shared();
|
|
8019
|
+
|
|
8020
|
+
// src/v2-entry/host-lease-state-store/host-lease-state-store.ts
|
|
8021
|
+
init_adapters();
|
|
8022
|
+
init_lease_state2();
|
|
8023
|
+
var hostLeaseStateStore = (options) => ({
|
|
8024
|
+
get: async () => {
|
|
8025
|
+
const value = await options.storage.get(options.key);
|
|
8026
|
+
if (value === void 0) {
|
|
8027
|
+
return void 0;
|
|
8028
|
+
}
|
|
8029
|
+
if (typeof value !== "string") {
|
|
8030
|
+
throw new ContractParseError("lease metadata must be a JSON string");
|
|
8031
|
+
}
|
|
8032
|
+
return LeaseState.restore(JSON.parse(value)).snapshot();
|
|
8033
|
+
},
|
|
8034
|
+
set: async (state) => {
|
|
8035
|
+
if (state === void 0) {
|
|
8036
|
+
await options.storage.remove(options.key);
|
|
8037
|
+
return;
|
|
8038
|
+
}
|
|
8039
|
+
await options.storage.set(options.key, JSON.stringify(state));
|
|
8040
|
+
}
|
|
8041
|
+
});
|
|
8042
|
+
|
|
8043
|
+
// src/v2-entry/host-token-store/host-token-store.ts
|
|
8044
|
+
var DEFAULT_TOKEN_KEY = "route33_auth";
|
|
8045
|
+
var LEGACY_TOKEN_KEY = "route33:auth";
|
|
8046
|
+
var hostTokenStore = (options) => {
|
|
8047
|
+
const key = options.key ?? DEFAULT_TOKEN_KEY;
|
|
8048
|
+
return {
|
|
8049
|
+
get: async () => {
|
|
8050
|
+
const value = await options.storage.get(key);
|
|
8051
|
+
if (typeof value === "string") {
|
|
8052
|
+
return value;
|
|
8053
|
+
}
|
|
8054
|
+
const legacy = await options.storage.get(LEGACY_TOKEN_KEY);
|
|
8055
|
+
return typeof legacy === "string" ? legacy : void 0;
|
|
8056
|
+
},
|
|
8057
|
+
set: async (value) => {
|
|
8058
|
+
if (value === void 0) {
|
|
8059
|
+
await options.storage.remove(key);
|
|
8060
|
+
} else {
|
|
8061
|
+
await options.storage.set(key, value);
|
|
8062
|
+
}
|
|
8063
|
+
await options.storage.remove(LEGACY_TOKEN_KEY);
|
|
8064
|
+
}
|
|
8065
|
+
};
|
|
8066
|
+
};
|
|
8067
|
+
|
|
8068
|
+
// src/tui-entry/v2-tui-box-storage/v2-tui-box-storage.ts
|
|
8069
|
+
var v2TuiBoxStorage = (options) => {
|
|
8070
|
+
const [box, mutate] = options.storage.store(options.key, { initial: {} });
|
|
8071
|
+
return {
|
|
8072
|
+
get: () => Promise.resolve(box.value),
|
|
8073
|
+
remove: async () => {
|
|
8074
|
+
await mutate((draft) => {
|
|
8075
|
+
draft.value = void 0;
|
|
8076
|
+
});
|
|
8077
|
+
},
|
|
8078
|
+
set: async (_key, value) => {
|
|
8079
|
+
await mutate((draft) => {
|
|
8080
|
+
draft.value = value;
|
|
8081
|
+
});
|
|
8082
|
+
}
|
|
8083
|
+
};
|
|
8084
|
+
};
|
|
8085
|
+
|
|
8086
|
+
// src/tui-entry/v2-tui-runtime/v2-tui-runtime.ts
|
|
8087
|
+
var composeV2TuiRuntime = (context) => {
|
|
8088
|
+
const { storage } = context;
|
|
8089
|
+
if (storage === void 0) {
|
|
8090
|
+
return void 0;
|
|
8091
|
+
}
|
|
8092
|
+
const box = (key) => v2TuiBoxStorage({ key, storage });
|
|
8093
|
+
const location = context.location ?? context.data?.location.default();
|
|
8094
|
+
const clientId = readEnvClientId() ?? DEFAULT_ROUTE33_CLIENT_ID;
|
|
8095
|
+
const production = buildProductionRuntimeOptions({
|
|
8096
|
+
apiBaseUrl: readEnvApiBase() ?? DEFAULT_MANAGEMENT_API_BASE_URL,
|
|
8097
|
+
clientId,
|
|
8098
|
+
issuerUrl: readEnvAuthIssuer() ?? DEFAULT_AUTH_ISSUER_URL,
|
|
8099
|
+
tokenStore: hostTokenStore({ storage: box("route33_auth") })
|
|
8100
|
+
});
|
|
8101
|
+
return new Route33Runtime({
|
|
8102
|
+
...production,
|
|
8103
|
+
auth: { ...production.auth, clientId },
|
|
8104
|
+
installation: createLeaseInstallationFactory({
|
|
8105
|
+
createSecretStore: (scopeId) => new HostStorageSecretStore({
|
|
8106
|
+
key: `route33_lease_${scopeId}`,
|
|
8107
|
+
storage: box(`route33_lease_${scopeId}`)
|
|
8108
|
+
}),
|
|
8109
|
+
createStateStore: (scopeId) => hostLeaseStateStore({
|
|
8110
|
+
key: `route33_lease_${scopeId}_state`,
|
|
8111
|
+
storage: box(`route33_lease_${scopeId}_state`)
|
|
8112
|
+
})
|
|
8113
|
+
}),
|
|
8114
|
+
state: {
|
|
8115
|
+
directory: location?.directory ?? "",
|
|
8116
|
+
outsideWorktree: "return-undefined"
|
|
8117
|
+
}
|
|
8118
|
+
});
|
|
8119
|
+
};
|
|
8120
|
+
|
|
8039
8121
|
// src/tui-entry/v2-wizard-control/v2-wizard-control.ts
|
|
8040
8122
|
var v2WizardControl = () => {
|
|
8041
8123
|
let menuRequested = false;
|
|
@@ -8054,6 +8136,8 @@ var v2WizardControl = () => {
|
|
|
8054
8136
|
var createV2Tui = () => ({
|
|
8055
8137
|
id: "route33",
|
|
8056
8138
|
setup: (context) => {
|
|
8139
|
+
const tuiRuntime = composeV2TuiRuntime(context);
|
|
8140
|
+
const menuHandlers = () => tuiRuntime?.commandHandlers();
|
|
8057
8141
|
context.keymap?.layer(() => ({
|
|
8058
8142
|
mode: "global",
|
|
8059
8143
|
priority: 10,
|
|
@@ -8070,7 +8154,7 @@ var createV2Tui = () => ({
|
|
|
8070
8154
|
run: async () => {
|
|
8071
8155
|
wizard.menuRequested();
|
|
8072
8156
|
try {
|
|
8073
|
-
await showR33Menu(context);
|
|
8157
|
+
await showR33Menu(context, { handlers: menuHandlers });
|
|
8074
8158
|
} finally {
|
|
8075
8159
|
wizard.menuClosed();
|
|
8076
8160
|
}
|
|
@@ -8110,8 +8194,9 @@ var createV2Tui = () => ({
|
|
|
8110
8194
|
switchModel: (input) => client.session?.switchModel?.(input) ?? Promise.resolve()
|
|
8111
8195
|
});
|
|
8112
8196
|
};
|
|
8113
|
-
const boot = async () => {
|
|
8197
|
+
const boot = async (options) => {
|
|
8114
8198
|
const outcome = await v2BootMatrix({
|
|
8199
|
+
assumedAlive: options?.assumedAlive === true,
|
|
8115
8200
|
attributed,
|
|
8116
8201
|
globalFallback: async () => {
|
|
8117
8202
|
const silent = await globalFallback();
|
|
@@ -8124,7 +8209,13 @@ var createV2Tui = () => ({
|
|
|
8124
8209
|
locationInput: { directory },
|
|
8125
8210
|
status
|
|
8126
8211
|
}),
|
|
8127
|
-
wizard: () => v2Autoconnect(
|
|
8212
|
+
wizard: () => v2Autoconnect(
|
|
8213
|
+
// The wizard re-derives its directory from the context
|
|
8214
|
+
// location, which is undefined until the first route lands —
|
|
8215
|
+
// inject the boot location so the budget picker opens.
|
|
8216
|
+
{ ...context, location },
|
|
8217
|
+
{ superseded: wizard.superseded }
|
|
8218
|
+
)
|
|
8128
8219
|
});
|
|
8129
8220
|
if (outcome.kind === "wizard-settled") {
|
|
8130
8221
|
void autoSelect().catch(() => void 0);
|
|
@@ -8144,13 +8235,11 @@ var createV2Tui = () => ({
|
|
|
8144
8235
|
run: boot
|
|
8145
8236
|
});
|
|
8146
8237
|
void lock.start().catch(() => void 0);
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
}
|
|
8153
|
-
void lock.start().catch(() => void 0);
|
|
8238
|
+
registerV2BootReentry({
|
|
8239
|
+
listen: context.data?.listen,
|
|
8240
|
+
pending: () => v2SetupDirectory({ location: { directory } }) !== void 0,
|
|
8241
|
+
start: () => lock.start({ assumedAlive: true }),
|
|
8242
|
+
superseded: wizard.superseded
|
|
8154
8243
|
});
|
|
8155
8244
|
}
|
|
8156
8245
|
});
|
package/dist/v2-entry/index.js
CHANGED
|
@@ -2553,7 +2553,7 @@ var createLeaseInstallationFactory = (options) => {
|
|
|
2553
2553
|
return existing;
|
|
2554
2554
|
}
|
|
2555
2555
|
const installation = {
|
|
2556
|
-
keyName: `
|
|
2556
|
+
keyName: `route33_lease_${scopeId}`,
|
|
2557
2557
|
secretStore: options.createSecretStore(scopeId),
|
|
2558
2558
|
...options.createStateStore === void 0 ? {} : { stateStore: options.createStateStore(scopeId) },
|
|
2559
2559
|
state: LeaseState.restore(void 0)
|
|
@@ -2871,11 +2871,14 @@ var Route33Runtime = class {
|
|
|
2871
2871
|
* member-visible project listing, organisation names stitched from the
|
|
2872
2872
|
* login's own memberships. Orgs the login merely administers carry no
|
|
2873
2873
|
* budget row and drop out — the picker never offers a project whose
|
|
2874
|
-
* keys the login cannot create.
|
|
2874
|
+
* keys the login cannot create. A `allowBrowser: false` policy makes
|
|
2875
|
+
* the call non-blocking: a dead session rejects instead of opening a
|
|
2876
|
+
* browser, so the picker's form registration never stalls a boot.
|
|
2877
|
+
* @param policy - Whether a dead session may open a browser login.
|
|
2875
2878
|
* @returns Mintable projects with organisation context for the picker.
|
|
2876
2879
|
*/
|
|
2877
|
-
async listMintableProjects() {
|
|
2878
|
-
const credential = await this.#session.credential();
|
|
2880
|
+
async listMintableProjects(policy = {}) {
|
|
2881
|
+
const credential = await this.#session.credential(policy);
|
|
2879
2882
|
const subject = this.#subject(credential);
|
|
2880
2883
|
const client = this.#client();
|
|
2881
2884
|
const [budgets, memberships] = await Promise.all([
|
|
@@ -4082,7 +4085,6 @@ var bootstrapProvider = async (deps, sink) => {
|
|
|
4082
4085
|
try {
|
|
4083
4086
|
await runtime2.login({ allowBrowser: false });
|
|
4084
4087
|
} catch {
|
|
4085
|
-
return;
|
|
4086
4088
|
}
|
|
4087
4089
|
await deps.registerProjectForm().catch(() => void 0);
|
|
4088
4090
|
try {
|
|
@@ -4203,39 +4205,34 @@ var createConnectAuthorize = (deps) => async (answer = {}) => {
|
|
|
4203
4205
|
if (detectWorktreeRoot(deps.directory) === void 0) {
|
|
4204
4206
|
throw new GatewayCredentialError(CONNECT_COPY.failFastWorktree);
|
|
4205
4207
|
}
|
|
4206
|
-
await applyWizardAnswer(deps, answer);
|
|
4207
|
-
if (readAttribution(deps.state) !== void 0) {
|
|
4208
|
-
const callback2 = deps.resolveCredential();
|
|
4209
|
-
const decision2 = await deps.stash.urlForConnect(
|
|
4210
|
-
callback2.then(() => void 0)
|
|
4211
|
-
);
|
|
4212
|
-
return {
|
|
4213
|
-
callback: callback2,
|
|
4214
|
-
instructions: decision2.instructions,
|
|
4215
|
-
mode: "auto",
|
|
4216
|
-
url: decision2.url
|
|
4217
|
-
};
|
|
4218
|
-
}
|
|
4219
|
-
const runtime2 = deps.getRuntime();
|
|
4220
|
-
if (runtime2 === void 0) {
|
|
4221
|
-
throw new GatewayCredentialError(
|
|
4222
|
-
"Route 33 authorization is unavailable in this host"
|
|
4223
|
-
);
|
|
4224
|
-
}
|
|
4225
4208
|
const callback = (async () => {
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4209
|
+
const emptyAnswer = Object.keys(answer).length === 0;
|
|
4210
|
+
if (emptyAnswer && readAttribution(deps.state) === void 0) {
|
|
4211
|
+
const runtime2 = deps.getRuntime();
|
|
4212
|
+
if (runtime2 === void 0) {
|
|
4213
|
+
throw new GatewayCredentialError(
|
|
4214
|
+
"Route 33 authorization is unavailable in this host"
|
|
4215
|
+
);
|
|
4216
|
+
}
|
|
4217
|
+
await runtime2.login({ allowBrowser: false });
|
|
4218
|
+
try {
|
|
4219
|
+
return await deps.resolveCredential();
|
|
4220
|
+
} catch (error) {
|
|
4221
|
+
if (error instanceof AttributionPromptError && error.code === "ATTRIBUTION_PRESENTER_UNAVAILABLE") {
|
|
4222
|
+
await deps.registerProjectForm();
|
|
4223
|
+
throw new GatewayCredentialError(CONNECT_COPY.signedInNextStep);
|
|
4224
|
+
}
|
|
4225
|
+
throw error;
|
|
4233
4226
|
}
|
|
4234
|
-
throw error;
|
|
4235
4227
|
}
|
|
4228
|
+
await applyWizardAnswer(deps, answer);
|
|
4229
|
+
if (readAttribution(deps.state) === void 0) {
|
|
4230
|
+
throw new GatewayCredentialError(CONNECT_COPY.selectionInvalid);
|
|
4231
|
+
}
|
|
4232
|
+
return deps.resolveCredential();
|
|
4236
4233
|
})();
|
|
4237
4234
|
const decision = await deps.stash.urlForConnect(
|
|
4238
|
-
callback.
|
|
4235
|
+
callback.then(() => void 0)
|
|
4239
4236
|
);
|
|
4240
4237
|
return {
|
|
4241
4238
|
callback,
|
|
@@ -4347,20 +4344,29 @@ var hostLeaseStateStore = (options) => ({
|
|
|
4347
4344
|
});
|
|
4348
4345
|
|
|
4349
4346
|
// src/v2-entry/host-token-store/host-token-store.ts
|
|
4350
|
-
var DEFAULT_TOKEN_KEY = "
|
|
4351
|
-
var
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4347
|
+
var DEFAULT_TOKEN_KEY = "route33_auth";
|
|
4348
|
+
var LEGACY_TOKEN_KEY = "route33:auth";
|
|
4349
|
+
var hostTokenStore = (options) => {
|
|
4350
|
+
const key = options.key ?? DEFAULT_TOKEN_KEY;
|
|
4351
|
+
return {
|
|
4352
|
+
get: async () => {
|
|
4353
|
+
const value = await options.storage.get(key);
|
|
4354
|
+
if (typeof value === "string") {
|
|
4355
|
+
return value;
|
|
4356
|
+
}
|
|
4357
|
+
const legacy = await options.storage.get(LEGACY_TOKEN_KEY);
|
|
4358
|
+
return typeof legacy === "string" ? legacy : void 0;
|
|
4359
|
+
},
|
|
4360
|
+
set: async (value) => {
|
|
4361
|
+
if (value === void 0) {
|
|
4362
|
+
await options.storage.remove(key);
|
|
4363
|
+
} else {
|
|
4364
|
+
await options.storage.set(key, value);
|
|
4365
|
+
}
|
|
4366
|
+
await options.storage.remove(LEGACY_TOKEN_KEY);
|
|
4360
4367
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
});
|
|
4368
|
+
};
|
|
4369
|
+
};
|
|
4364
4370
|
|
|
4365
4371
|
// src/v2-entry/mint-and-refresh/mint-and-refresh.ts
|
|
4366
4372
|
var mintAndRefresh = async (deps, attribution, extras) => {
|
|
@@ -4369,66 +4375,6 @@ var mintAndRefresh = async (deps, attribution, extras) => {
|
|
|
4369
4375
|
return minted;
|
|
4370
4376
|
};
|
|
4371
4377
|
|
|
4372
|
-
// src/v2-entry/format-inspect-reply/format-inspect-reply.ts
|
|
4373
|
-
var formatInspectReply = (inspection) => {
|
|
4374
|
-
const lines = [];
|
|
4375
|
-
if (inspection.attribution === void 0) {
|
|
4376
|
-
return "Route 33 is not connected in this folder \u2014 run /connect or /r33 to set a budget.";
|
|
4377
|
-
}
|
|
4378
|
-
lines.push(
|
|
4379
|
-
inspection.attribution.kind === "personal" ? "Budget: Personal" : `Budget: Project ${inspection.attribution.projectId}`
|
|
4380
|
-
);
|
|
4381
|
-
if (inspection.key !== void 0) {
|
|
4382
|
-
const scope = inspection.key.projectName === null ? "your personal budget" : `${inspection.key.organisationName ?? "unknown organisation"} \xB7 ${inspection.key.projectName}`;
|
|
4383
|
-
lines.push(`Key: ${inspection.key.name} on ${scope}`);
|
|
4384
|
-
}
|
|
4385
|
-
if (inspection.lease !== void 0) {
|
|
4386
|
-
lines.push(`Expires: ${inspection.lease.expiresAt}`);
|
|
4387
|
-
lines.push(`Key id: ${inspection.lease.keyId}`);
|
|
4388
|
-
}
|
|
4389
|
-
return lines.join("\n");
|
|
4390
|
-
};
|
|
4391
|
-
|
|
4392
|
-
// src/v2-entry/parse-r33-subcommand/parse-r33-subcommand.ts
|
|
4393
|
-
var SUBCOMMANDS = ["inspect", "logout", "rotate", "reset"];
|
|
4394
|
-
var parseR33Subcommand = (promptText) => {
|
|
4395
|
-
const [first = "", ...rest] = promptText.trim().split(/\s+/u).filter(Boolean);
|
|
4396
|
-
const name = first.replace(/^\/+/u, "").split(":")[0] ?? "";
|
|
4397
|
-
const argument = name === "r33" ? rest[0] : first;
|
|
4398
|
-
if (argument === void 0 || argument === "") {
|
|
4399
|
-
return "inspect";
|
|
4400
|
-
}
|
|
4401
|
-
return SUBCOMMANDS.includes(argument) ? argument : "help";
|
|
4402
|
-
};
|
|
4403
|
-
|
|
4404
|
-
// src/v2-entry/r33-command/r33-command.ts
|
|
4405
|
-
var executeR33Command = async (input) => {
|
|
4406
|
-
const subcommand = parseR33Subcommand(input.promptText);
|
|
4407
|
-
if (input.handlers === void 0) {
|
|
4408
|
-
return "Route 33 is not connected in this folder. Run /connect, choose Route 33, and follow the steps.";
|
|
4409
|
-
}
|
|
4410
|
-
if (subcommand === "help") {
|
|
4411
|
-
return "Route 33 usage: /r33 [inspect|rotate|reset|logout] \u2014 inspect shows attribution and key rotation, rotate rotates the key now, reset clears the assigned budget (assign again with /connect).";
|
|
4412
|
-
}
|
|
4413
|
-
switch (subcommand) {
|
|
4414
|
-
case "rotate": {
|
|
4415
|
-
const lease = await input.handlers["rotate-now"]();
|
|
4416
|
-
return `Route 33 key rotated. Key ${lease.keyId} is valid until ${lease.expiresAt}.`;
|
|
4417
|
-
}
|
|
4418
|
-
case "logout": {
|
|
4419
|
-
await input.handlers["logout"]();
|
|
4420
|
-
return "Logged out of Route 33 \u2014 the next OpenCode start signs in again.";
|
|
4421
|
-
}
|
|
4422
|
-
case "reset": {
|
|
4423
|
-
await input.handlers["reset-attribution"]();
|
|
4424
|
-
return "Route 33 attribution cleared. Run /connect, choose Route 33, and assign a budget again.";
|
|
4425
|
-
}
|
|
4426
|
-
default: {
|
|
4427
|
-
return formatInspectReply(await input.handlers["inspect-session"]());
|
|
4428
|
-
}
|
|
4429
|
-
}
|
|
4430
|
-
};
|
|
4431
|
-
|
|
4432
4378
|
// src/v2-entry/model-gate-notify-from/model-gate-notify-from.ts
|
|
4433
4379
|
var notifyFrom = async (session, sessionID, message) => {
|
|
4434
4380
|
await session.synthetic?.({ delivery: "queue", sessionID, text: message });
|
|
@@ -4522,7 +4468,7 @@ var registerRoute33ModelGate = async (deps) => deps.session.hook(
|
|
|
4522
4468
|
);
|
|
4523
4469
|
|
|
4524
4470
|
// src/v2-entry/resolve-host-credential/resolve-host-credential.ts
|
|
4525
|
-
var NO_USABLE_LEASE_MESSAGE = "Route 33
|
|
4471
|
+
var NO_USABLE_LEASE_MESSAGE = "Signed in to Route 33 \u2713. One more step: this folder has no gateway key yet \u2014 pick its budget to finish setup.";
|
|
4526
4472
|
var resolveHostCredential = async (deps) => {
|
|
4527
4473
|
await deps.config();
|
|
4528
4474
|
deps.onProvider(deps.parseProvider(void 0));
|
|
@@ -4576,11 +4522,11 @@ var createRoute33V2Plugin = (options = {}) => {
|
|
|
4576
4522
|
};
|
|
4577
4523
|
const installation = createLeaseInstallationFactory({
|
|
4578
4524
|
createSecretStore: (scopeId) => new HostStorageSecretStore({
|
|
4579
|
-
key: `
|
|
4525
|
+
key: `route33_lease_${scopeId}`,
|
|
4580
4526
|
storage: context.storage
|
|
4581
4527
|
}),
|
|
4582
4528
|
createStateStore: (scopeId) => hostLeaseStateStore({
|
|
4583
|
-
key: `
|
|
4529
|
+
key: `route33_lease_${scopeId}_state`,
|
|
4584
4530
|
storage: context.storage
|
|
4585
4531
|
})
|
|
4586
4532
|
});
|
|
@@ -4626,7 +4572,7 @@ var createRoute33V2Plugin = (options = {}) => {
|
|
|
4626
4572
|
return;
|
|
4627
4573
|
}
|
|
4628
4574
|
const [projects, modelIds, personalKeyActive] = await Promise.all([
|
|
4629
|
-
activeRuntime.listMintableProjects(),
|
|
4575
|
+
activeRuntime.listMintableProjects({ allowBrowser: false }).catch(() => []),
|
|
4630
4576
|
activeRuntime.catalogModelIds(),
|
|
4631
4577
|
activeRuntime.hasPersonalLease().catch(() => false)
|
|
4632
4578
|
]);
|
|
@@ -4680,23 +4626,6 @@ var createRoute33V2Plugin = (options = {}) => {
|
|
|
4680
4626
|
});
|
|
4681
4627
|
}
|
|
4682
4628
|
);
|
|
4683
|
-
const commandTransform = await context.command.transform((editor) => {
|
|
4684
|
-
editor.add({
|
|
4685
|
-
description: "Route 33 actions: /r33 [inspect|rotate|reset|logout] \u2014 inspect shows attribution and key details, rotate rotates the key now, reset clears the assigned budget, logout signs out of Route 33",
|
|
4686
|
-
execute: async ({ prompt, sessionID }) => {
|
|
4687
|
-
const text = await executeR33Command({
|
|
4688
|
-
handlers: runtime2?.commandHandlers(),
|
|
4689
|
-
promptText: prompt.text
|
|
4690
|
-
});
|
|
4691
|
-
await context.session.synthetic({
|
|
4692
|
-
delivery: "queue",
|
|
4693
|
-
sessionID,
|
|
4694
|
-
text
|
|
4695
|
-
});
|
|
4696
|
-
},
|
|
4697
|
-
name: "r33"
|
|
4698
|
-
});
|
|
4699
|
-
});
|
|
4700
4629
|
const sessionHook = await context.session.hook(
|
|
4701
4630
|
"http.request",
|
|
4702
4631
|
createWorkspaceKeyHook({
|
|
@@ -4730,7 +4659,6 @@ var createRoute33V2Plugin = (options = {}) => {
|
|
|
4730
4659
|
]);
|
|
4731
4660
|
return async () => {
|
|
4732
4661
|
await Promise.all([
|
|
4733
|
-
commandTransform.dispose(),
|
|
4734
4662
|
integrationTransform.dispose(),
|
|
4735
4663
|
providerTransform.dispose(),
|
|
4736
4664
|
sessionHook.dispose(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r-33/opencode",
|
|
3
|
-
"version": "0.4.7-rc.
|
|
3
|
+
"version": "0.4.7-rc.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"eslint": "10.13.0",
|
|
47
47
|
"typescript": "6.0.3",
|
|
48
48
|
"vitest": "5.0.5",
|
|
49
|
-
"@cronos-ai-lab/
|
|
50
|
-
"@cronos-ai-lab/
|
|
49
|
+
"@cronos-ai-lab/eslint-config": "0.2.1-rc.2",
|
|
50
|
+
"@cronos-ai-lab/typescript-config": "0.2.1-rc.2"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"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:-}\\\"",
|