@r-33/opencode 0.5.1-rc.0 → 0.5.1

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/README.md CHANGED
@@ -100,7 +100,8 @@ terminal.
100
100
 
101
101
  Outside a Git repository a folder has no budget of its own: `/connect`
102
102
  offers your personal key, and that one choice covers every such folder on
103
- this machine.
103
+ this machine. To change it, open `/r33`: **Attribute** in such a folder,
104
+ **Global key** inside a repository.
104
105
 
105
106
  ## Session cost
106
107
 
package/dist/index.js CHANGED
@@ -1783,6 +1783,7 @@ var globalAttributionFile = () => path8.join(resolveV1SecretStoreDirectory(), "r
1783
1783
  // src/attribution/resolve-attribution-file/resolve-attribution-file.ts
1784
1784
  var STATE_FILE = "route33.attribution.json";
1785
1785
  var resolveAttributionFile = (options) => {
1786
+ if (options.scope === "global") return globalAttributionFile();
1786
1787
  const worktreeRoot = detectWorktreeRoot(options.directory);
1787
1788
  if (worktreeRoot !== void 0) {
1788
1789
  return path9.join(worktreeRoot, ".opencode", STATE_FILE);
@@ -1816,7 +1817,7 @@ var clearAttribution = (options) => {
1816
1817
  };
1817
1818
 
1818
1819
  // src/attribution/is-global-attribution/is-global-attribution.ts
1819
- var isGlobalAttribution = (options) => options.outsideWorktree === "use-global" && detectWorktreeRoot(options.directory) === void 0;
1820
+ var isGlobalAttribution = (options) => options.scope === "global" || options.outsideWorktree === "use-global" && detectWorktreeRoot(options.directory) === void 0;
1820
1821
 
1821
1822
  // src/attribution/is-global-choice/is-global-choice.ts
1822
1823
  var isGlobalChoice = (attribution) => attribution.kind === "personal" && attribution.boundKeyId === void 0;
@@ -3541,10 +3542,11 @@ var Route33Runtime = class {
3541
3542
  }
3542
3543
  /**
3543
3544
  * Reads the stored key for a saved attribution without any login.
3545
+ * @param state - Whose attribution to read; this folder's by default.
3544
3546
  * @returns The reusable key and lease when the stored lease is still valid.
3545
3547
  */
3546
- async storedReusableKey() {
3547
- const attribution = readAttribution(this.#options.state);
3548
+ async storedReusableKey(state = this.#options.state) {
3549
+ const attribution = readAttribution(state);
3548
3550
  if (attribution === void 0) {
3549
3551
  return void 0;
3550
3552
  }
@@ -3711,10 +3713,11 @@ var Route33Runtime = class {
3711
3713
  * @param extras - The wizard's key-creation answers.
3712
3714
  * @param directory - Optional worktree override for project leases.
3713
3715
  * @param saveAttribution - Wizard save that must succeed before replacing a live key.
3716
+ * @param state - Where that save lands; the directory's own state by default.
3714
3717
  * @returns The fresh key material with its lease metadata.
3715
3718
  */
3716
- async mintWorkspaceKey(attribution, extras, directory = this.#options.state.directory, saveAttribution) {
3717
- const file = resolveAttributionFile({ ...this.#options.state, directory });
3719
+ async mintWorkspaceKey(attribution, extras, directory = this.#options.state.directory, saveAttribution, state = { ...this.#options.state, directory }) {
3720
+ const file = resolveAttributionFile(state);
3718
3721
  if (file === void 0)
3719
3722
  throw new TypeError("Workspace attribution requires a worktree");
3720
3723
  const previous = statSync2(file, { bigint: true, throwIfNoEntry: false });
@@ -4031,6 +4031,7 @@ var init_resolve_attribution_file = __esm({
4031
4031
  init_global_attribution_file2();
4032
4032
  STATE_FILE = "route33.attribution.json";
4033
4033
  resolveAttributionFile = (options) => {
4034
+ if (options.scope === "global") return globalAttributionFile();
4034
4035
  const worktreeRoot = detectWorktreeRoot(options.directory);
4035
4036
  if (worktreeRoot !== void 0) {
4036
4037
  return path9.join(worktreeRoot, ".opencode", STATE_FILE);
@@ -4095,7 +4096,7 @@ var init_is_global_attribution = __esm({
4095
4096
  "src/attribution/is-global-attribution/is-global-attribution.ts"() {
4096
4097
  "use strict";
4097
4098
  init_detect_worktree_root2();
4098
- isGlobalAttribution = (options) => options.outsideWorktree === "use-global" && detectWorktreeRoot(options.directory) === void 0;
4099
+ isGlobalAttribution = (options) => options.scope === "global" || options.outsideWorktree === "use-global" && detectWorktreeRoot(options.directory) === void 0;
4099
4100
  }
4100
4101
  });
4101
4102
 
@@ -6045,9 +6046,12 @@ var init_attribution_prompt = __esm({
6045
6046
  });
6046
6047
 
6047
6048
  // src/ux/attribution-prompt/is-personal-selection/is-personal-selection.ts
6049
+ var PERSONAL_SELECTION_SUFFIX, isPersonalSelection;
6048
6050
  var init_is_personal_selection = __esm({
6049
6051
  "src/ux/attribution-prompt/is-personal-selection/is-personal-selection.ts"() {
6050
6052
  "use strict";
6053
+ PERSONAL_SELECTION_SUFFIX = ":personal";
6054
+ isPersonalSelection = (selection) => selection === "personal" || selection.endsWith(PERSONAL_SELECTION_SUFFIX);
6051
6055
  }
6052
6056
  });
6053
6057
 
@@ -6648,10 +6652,11 @@ var init_route33_runtime = __esm({
6648
6652
  }
6649
6653
  /**
6650
6654
  * Reads the stored key for a saved attribution without any login.
6655
+ * @param state - Whose attribution to read; this folder's by default.
6651
6656
  * @returns The reusable key and lease when the stored lease is still valid.
6652
6657
  */
6653
- async storedReusableKey() {
6654
- const attribution = readAttribution(this.#options.state);
6658
+ async storedReusableKey(state = this.#options.state) {
6659
+ const attribution = readAttribution(state);
6655
6660
  if (attribution === void 0) {
6656
6661
  return void 0;
6657
6662
  }
@@ -6818,10 +6823,11 @@ var init_route33_runtime = __esm({
6818
6823
  * @param extras - The wizard's key-creation answers.
6819
6824
  * @param directory - Optional worktree override for project leases.
6820
6825
  * @param saveAttribution - Wizard save that must succeed before replacing a live key.
6826
+ * @param state - Where that save lands; the directory's own state by default.
6821
6827
  * @returns The fresh key material with its lease metadata.
6822
6828
  */
6823
- async mintWorkspaceKey(attribution, extras, directory = this.#options.state.directory, saveAttribution) {
6824
- const file = resolveAttributionFile({ ...this.#options.state, directory });
6829
+ async mintWorkspaceKey(attribution, extras, directory = this.#options.state.directory, saveAttribution, state = { ...this.#options.state, directory }) {
6830
+ const file = resolveAttributionFile(state);
6825
6831
  if (file === void 0)
6826
6832
  throw new TypeError("Workspace attribution requires a worktree");
6827
6833
  const previous = statSync2(file, { bigint: true, throwIfNoEntry: false });
@@ -8601,6 +8607,51 @@ init_attribution();
8601
8607
  init_attribution();
8602
8608
  init_cli();
8603
8609
 
8610
+ // src/tui-entry/show-r33-menu/menu-options/menu-options.ts
8611
+ var GLOBAL_KEY_SUBJECT = "the key for folders outside Git";
8612
+ var r33MenuOptions = (outsideGit) => [
8613
+ ...outsideGit ? [{ title: `Attribute \u2014 ${GLOBAL_KEY_SUBJECT}`, value: "attribute" }] : [
8614
+ {
8615
+ title: "Attribute \u2014 pick this folder's budget again",
8616
+ value: "attribute"
8617
+ },
8618
+ { title: `Global key \u2014 ${GLOBAL_KEY_SUBJECT}`, value: "global" }
8619
+ ],
8620
+ {
8621
+ title: "Inspect session \u2014 attribution and key metadata",
8622
+ value: "inspect"
8623
+ },
8624
+ { title: "Rotate key now", value: "rotate" }
8625
+ ];
8626
+
8627
+ // src/tui-entry/show-r33-menu/run-action/run-action.ts
8628
+ var runR33MenuAction = async (context, action, deps) => {
8629
+ try {
8630
+ const handlers = deps.handlers();
8631
+ const local = () => executeR33Command({
8632
+ budgetAction: "Attribute",
8633
+ handlers: handlers && {
8634
+ ...handlers,
8635
+ "inspect-session": async () => {
8636
+ const inspection = await handlers["inspect-session"]();
8637
+ return inspection.connected || deps.signedIn === void 0 ? inspection : { ...inspection, connected: await deps.signedIn() };
8638
+ }
8639
+ },
8640
+ promptText: `/r33 ${action}`
8641
+ });
8642
+ const reply = action === "rotate" && deps.rotate !== void 0 ? await deps.rotate() : await local();
8643
+ context.ui.toast.show({ message: reply, variant: "info" });
8644
+ } catch (error) {
8645
+ context.ui.toast.show({
8646
+ message: error instanceof Error ? error.message : String(error),
8647
+ variant: "error"
8648
+ });
8649
+ }
8650
+ };
8651
+
8652
+ // src/tui-entry/show-r33-menu/run-budget-entry/run-budget-entry.ts
8653
+ init_attribution();
8654
+
8604
8655
  // src/tui-entry/v2-autoconnect/v2-autoconnect.ts
8605
8656
  init_attribution();
8606
8657
 
@@ -8611,6 +8662,7 @@ var V2_CONNECT_COPY = {
8611
8662
  busyTitle: "Route 33",
8612
8663
  dismissed: "Route 33 is not set up for this folder; open /r33 and choose Attribute.",
8613
8664
  expired: "Route 33 setup expired; open /r33 and choose Attribute.",
8665
+ globalKeyNotice: "This picks the personal key for every folder outside Git on this machine. This repository keeps its own budget.",
8614
8666
  manualFallback: "Guided Route 33 setup is unavailable; run /connect and choose Route 33.",
8615
8667
  manualPath: "Open /r33 and choose Attribute.",
8616
8668
  noBudgetsTitle: "Route 33 \u2014 no budgets available",
@@ -8774,9 +8826,29 @@ var answerPass = async (deps) => {
8774
8826
  return "refused";
8775
8827
  };
8776
8828
 
8777
- // src/v2-entry/connect-form/connect-form.ts
8778
- var ATTRIBUTION_FIELD_KEY2 = "attribution";
8829
+ // src/v2-entry/global-key-answer/global-key-answer.ts
8830
+ var ATTRIBUTION_SCOPE_FIELD_KEY = "attribution_scope";
8831
+ var GLOBAL_KEY_ANSWER = { [ATTRIBUTION_SCOPE_FIELD_KEY]: "global" };
8832
+ var isGlobalKeyAnswer = (answer) => answer[ATTRIBUTION_SCOPE_FIELD_KEY] === "global";
8833
+
8834
+ // src/v2-entry/connect-form/budget-question-copy/budget-question-copy.ts
8835
+ var budgetQuestionCopy = (plan) => plan.notice === void 0 ? {
8836
+ attribution: {
8837
+ title: "Which budget covers Route 33 usage in this folder?"
8838
+ },
8839
+ organisation: "Which Route 33 organisation covers this folder?"
8840
+ } : {
8841
+ attribution: {
8842
+ description: plan.notice,
8843
+ title: "Which personal key covers folders outside Git?"
8844
+ },
8845
+ organisation: "Which Route 33 organisation covers folders outside Git?"
8846
+ };
8847
+
8848
+ // src/v2-entry/connect-form/budget-fields/budget-fields.ts
8779
8849
  var ORGANISATION_FIELD_KEY = "organisation";
8850
+
8851
+ // src/v2-entry/connect-form/connect-form.ts
8780
8852
  var BUDGET_CAP_FIELD_KEY = "budget_cap";
8781
8853
  var BUDGET_CAP_MAX_FIELD_KEY = "budget_cap_max";
8782
8854
  var PREPARED_BUDGET_FIELD_KEY = "prepared_budget";
@@ -8998,7 +9070,7 @@ var prepareKeyFields = async (deps) => {
8998
9070
  (field) => field.key === PREPARED_BUDGET_FIELD_KEY
8999
9071
  )?.placeholder;
9000
9072
  const fields = registered.filter(
9001
- (field) => field.key !== ATTRIBUTION_FIELD_KEY2 && field.key !== ORGANISATION_FIELD_KEY && field.key !== PREPARED_BUDGET_FIELD_KEY
9073
+ (field) => field.key !== ATTRIBUTION_FIELD_KEY && field.key !== ATTRIBUTION_SCOPE_FIELD_KEY && field.key !== ORGANISATION_FIELD_KEY && field.key !== PREPARED_BUDGET_FIELD_KEY
9002
9074
  );
9003
9075
  if (fields.length === 0 || (preparedFor ?? deps.selection) !== deps.selection) {
9004
9076
  deps.toast({ message: V2_CONNECT_COPY.setupIncomplete, variant: "error" });
@@ -9013,7 +9085,7 @@ var runAnswerStep = async (deps) => {
9013
9085
  busy: { message, title: V2_CONNECT_COPY.busyTitle },
9014
9086
  connect: deps.connect,
9015
9087
  dialog: deps.dialog,
9016
- extras,
9088
+ extras: { ...deps.answers, ...extras },
9017
9089
  form: { key: deps.attributionFieldKey },
9018
9090
  locationInput: deps.locationInput,
9019
9091
  ...onBudgetSelected === void 0 ? {} : { onBudgetSelected },
@@ -9130,6 +9202,7 @@ var runBudgetRound = async (deps) => {
9130
9202
  }
9131
9203
  current = selection;
9132
9204
  const result = await runAnswerStep({
9205
+ answers: deps.answers,
9133
9206
  attributionFieldKey: "attribution",
9134
9207
  budgetOptions: scoped,
9135
9208
  draft,
@@ -9164,38 +9237,65 @@ var runBudgetRound = async (deps) => {
9164
9237
  }
9165
9238
  };
9166
9239
 
9240
+ // src/tui-entry/v2-budget-picker/budget-view/budget-view.ts
9241
+ init_ux();
9242
+ var budgetView = (fields, global) => {
9243
+ const field = (key) => fields.find((entry) => entry.key === key);
9244
+ const attribution = field(ATTRIBUTION_FIELD_KEY);
9245
+ if (attribution === void 0) return void 0;
9246
+ const orgs = field(ORGANISATION_FIELD_KEY);
9247
+ const folder = {
9248
+ answers: {},
9249
+ budgetOptions: attribution.options ?? [],
9250
+ budgetTitle: attribution.title,
9251
+ notice: attribution.description,
9252
+ orgTitle: orgs?.title,
9253
+ orgs: orgs?.options ?? []
9254
+ };
9255
+ if (!global) return folder;
9256
+ if (field(ATTRIBUTION_SCOPE_FIELD_KEY) === void 0) return void 0;
9257
+ const notice = V2_CONNECT_COPY.globalKeyNotice;
9258
+ const copy = budgetQuestionCopy({ notice });
9259
+ return {
9260
+ ...folder,
9261
+ answers: GLOBAL_KEY_ANSWER,
9262
+ budgetOptions: folder.budgetOptions.filter(
9263
+ ({ value }) => isPersonalSelection(value)
9264
+ ),
9265
+ budgetTitle: copy.attribution.title,
9266
+ notice,
9267
+ orgTitle: copy.organisation
9268
+ };
9269
+ };
9270
+
9167
9271
  // src/tui-entry/v2-budget-picker/v2-budget-picker.ts
9168
9272
  var v2BudgetPicker = async (deps) => {
9169
9273
  if (!deps.unattributed()) {
9170
9274
  deps.toast({ message: V2_CONNECT_COPY.success, variant: "success" });
9171
9275
  return;
9172
9276
  }
9173
- const attributionField = deps.formFields.find(
9174
- (field) => field.key === ATTRIBUTION_FIELD_KEY
9175
- );
9176
- if (attributionField === void 0) {
9277
+ const view = budgetView(deps.formFields, deps.global === true);
9278
+ if (view === void 0) {
9177
9279
  deps.toast({ message: V2_CONNECT_COPY.manualFallback, variant: "error" });
9178
9280
  return;
9179
9281
  }
9180
- const orgField = deps.formFields.find(
9181
- (field) => field.key === ORGANISATION_FIELD_KEY
9182
- );
9183
- if (attributionField.description !== void 0) {
9282
+ if (view.notice !== void 0) {
9184
9283
  await deps.dialog.alert({
9185
- message: attributionField.description,
9284
+ message: view.notice,
9186
9285
  title: V2_CONNECT_COPY.busyTitle
9187
9286
  });
9188
9287
  }
9189
9288
  for (; ; ) {
9190
9289
  const round = await runBudgetRound({
9191
- budgetOptions: attributionField.options ?? [],
9192
- budgetTitle: attributionField.title,
9290
+ answers: view.answers,
9291
+ budgetOptions: view.budgetOptions,
9292
+ budgetTitle: view.budgetTitle,
9193
9293
  connect: deps.connect,
9194
9294
  context: deps.context,
9195
9295
  dialog: deps.dialog,
9196
9296
  locationInput: deps.locationInput,
9197
- orgTitle: orgField?.title,
9198
- orgs: orgField?.options ?? [],
9297
+ orgTitle: view.orgTitle,
9298
+ orgs: view.orgs,
9199
9299
  pollTerminal: deps.pollTerminal,
9200
9300
  toast: deps.toast,
9201
9301
  unattributed: deps.unattributed
@@ -9349,6 +9449,7 @@ var v2GuidedConnect = async (deps) => {
9349
9449
  context,
9350
9450
  dialog,
9351
9451
  formFields,
9452
+ global: deps.global,
9352
9453
  locationInput,
9353
9454
  pollTerminal,
9354
9455
  toast,
@@ -9417,63 +9518,34 @@ var v2Autoconnect = async (context, options = {}) => {
9417
9518
  });
9418
9519
  };
9419
9520
 
9420
- // src/tui-entry/show-r33-menu/run-action/run-action.ts
9421
- var runR33MenuAction = async (context, action, deps) => {
9422
- try {
9423
- const handlers = deps.handlers();
9424
- const local = () => executeR33Command({
9425
- budgetAction: "Attribute",
9426
- handlers: handlers && {
9427
- ...handlers,
9428
- "inspect-session": async () => {
9429
- const inspection = await handlers["inspect-session"]();
9430
- return inspection.connected || deps.signedIn === void 0 ? inspection : { ...inspection, connected: await deps.signedIn() };
9431
- }
9432
- },
9433
- promptText: `/r33 ${action}`
9434
- });
9435
- const reply = action === "rotate" && deps.rotate !== void 0 ? await deps.rotate() : await local();
9436
- context.ui.toast.show({ message: reply, variant: "info" });
9437
- } catch (error) {
9438
- context.ui.toast.show({
9439
- message: error instanceof Error ? error.message : String(error),
9440
- variant: "error"
9441
- });
9521
+ // src/tui-entry/show-r33-menu/run-budget-entry/run-budget-entry.ts
9522
+ var runBudgetEntry = async (context, entry, state) => {
9523
+ if (entry === "global") {
9524
+ await v2GuidedConnect({ context, global: true, unattributed: () => true });
9525
+ return;
9526
+ }
9527
+ if (readAttribution(state) === void 0) {
9528
+ await v2Autoconnect(context, { directory: state.directory });
9529
+ return;
9442
9530
  }
9531
+ await v2GuidedConnect({ context, unattributed: () => true });
9443
9532
  };
9444
9533
 
9445
9534
  // src/tui-entry/show-r33-menu/show-r33-menu.ts
9446
- var menuOptions2 = [
9447
- {
9448
- title: "Attribute \u2014 pick this folder's budget again",
9449
- value: "attribute"
9450
- },
9451
- {
9452
- title: "Inspect session \u2014 attribution and key metadata",
9453
- value: "inspect"
9454
- },
9455
- {
9456
- title: "Rotate key now",
9457
- value: "rotate"
9458
- }
9459
- ];
9460
9535
  var showR33Menu = async (context, deps) => {
9536
+ const location = context.location ?? context.data?.location.default();
9537
+ const state = location && {
9538
+ directory: location.directory,
9539
+ outsideWorktree: "use-global"
9540
+ };
9461
9541
  const selection = await context.ui.dialog.select({
9462
9542
  title: "Route 33 \u2014 choose an action",
9463
- options: menuOptions2
9543
+ options: r33MenuOptions(state !== void 0 && isGlobalAttribution(state))
9464
9544
  });
9465
9545
  if (selection === void 0) return;
9466
- if (selection === "attribute") {
9467
- const location = context.location ?? context.data?.location.default();
9468
- if (location === void 0 || readEnvDirectApiKey() !== void 0) return;
9469
- if (readAttribution({
9470
- directory: location.directory,
9471
- outsideWorktree: "use-global"
9472
- }) === void 0) {
9473
- await v2Autoconnect(context, { directory: location.directory });
9474
- } else {
9475
- await v2GuidedConnect({ context, unattributed: () => true });
9476
- }
9546
+ if (selection === "attribute" || selection === "global") {
9547
+ if (state === void 0 || readEnvDirectApiKey() !== void 0) return;
9548
+ await runBudgetEntry(context, selection, state);
9477
9549
  return;
9478
9550
  }
9479
9551
  await runR33MenuAction(context, selection, deps);
@@ -9718,6 +9790,35 @@ var v2SetupLock = (deps) => {
9718
9790
  return { start: settle };
9719
9791
  };
9720
9792
 
9793
+ // src/tui-entry/v2-single-account/v2-single-account.ts
9794
+ init_predicates();
9795
+ var registerV2SingleAccount = (deps) => {
9796
+ const list = deps.client?.credential?.list;
9797
+ const remove = deps.client?.credential?.remove;
9798
+ if (list === void 0 || remove === void 0) return;
9799
+ const prune = async () => {
9800
+ const accounts = (await list()).filter(
9801
+ ({ integrationID }) => integrationID === "route33"
9802
+ );
9803
+ const kept = accounts.find(({ active }) => active) ?? accounts.at(-1);
9804
+ for (const { id } of accounts) {
9805
+ if (id !== kept?.id) await remove({ credentialID: id });
9806
+ }
9807
+ };
9808
+ let queue = Promise.resolve();
9809
+ const schedule = () => {
9810
+ queue = queue.then(prune).catch(() => void 0);
9811
+ };
9812
+ schedule();
9813
+ deps.data?.listen?.(({ details }) => {
9814
+ const event = details;
9815
+ const data = isRecord(event) ? event["data"] : void 0;
9816
+ if (details.type === "credential.switched" && isRecord(data) && data["integrationID"] === "route33" && typeof data["credentialID"] === "string") {
9817
+ schedule();
9818
+ }
9819
+ });
9820
+ };
9821
+
9721
9822
  // src/tui-entry/v2-tui-runtime/v2-tui-runtime.ts
9722
9823
  init_cli();
9723
9824
  init_host_storage_secret_store2();
@@ -9890,7 +9991,7 @@ var v2AutoSelectModel = async (context) => {
9890
9991
 
9891
9992
  // src/tui-entry/v2-tui/with-attribution-picker/with-attribution-picker.ts
9892
9993
  var withAttributionPicker = async (context, run) => {
9893
- const attempt = { complete: false };
9994
+ const attempt = { complete: false, global: false };
9894
9995
  let notice;
9895
9996
  const location = context.location ?? context.data?.location.default();
9896
9997
  const client = {
@@ -9899,10 +10000,17 @@ var withAttributionPicker = async (context, run) => {
9899
10000
  const integration = v2IntegrationSurface(context);
9900
10001
  const status = integration?.oauth?.status;
9901
10002
  if (!status) return integration;
10003
+ const connect = integration.oauth.connect;
9902
10004
  return {
9903
10005
  ...integration,
9904
10006
  oauth: {
9905
10007
  ...integration.oauth,
10008
+ ...connect && {
10009
+ connect: (input) => {
10010
+ attempt.global ||= isGlobalKeyAnswer(input.answer ?? {});
10011
+ return connect(input);
10012
+ }
10013
+ },
9906
10014
  status: async (input) => {
9907
10015
  const result = await status(input);
9908
10016
  attempt.complete = result.data.status === "complete";
@@ -9928,7 +10036,7 @@ var withAttributionPicker = async (context, run) => {
9928
10036
  }
9929
10037
  }
9930
10038
  });
9931
- if (!attempt.complete) return;
10039
+ if (!attempt.complete || attempt.global) return;
9932
10040
  await notice;
9933
10041
  await v2AutoSelectModel({ ...context, location }).catch(() => {
9934
10042
  context.ui.toast.show({
@@ -10060,6 +10168,7 @@ var createV2Tui = () => ({
10060
10168
  location,
10061
10169
  runtime: tuiRuntime
10062
10170
  });
10171
+ registerV2SingleAccount({ client: context.client, data: context.data });
10063
10172
  }
10064
10173
  });
10065
10174
 
@@ -1783,6 +1783,7 @@ var globalAttributionFile = () => path8.join(resolveV1SecretStoreDirectory(), "r
1783
1783
  // src/attribution/resolve-attribution-file/resolve-attribution-file.ts
1784
1784
  var STATE_FILE = "route33.attribution.json";
1785
1785
  var resolveAttributionFile = (options) => {
1786
+ if (options.scope === "global") return globalAttributionFile();
1786
1787
  const worktreeRoot = detectWorktreeRoot(options.directory);
1787
1788
  if (worktreeRoot !== void 0) {
1788
1789
  return path9.join(worktreeRoot, ".opencode", STATE_FILE);
@@ -1816,7 +1817,7 @@ var clearAttribution = (options) => {
1816
1817
  };
1817
1818
 
1818
1819
  // src/attribution/is-global-attribution/is-global-attribution.ts
1819
- var isGlobalAttribution = (options) => options.outsideWorktree === "use-global" && detectWorktreeRoot(options.directory) === void 0;
1820
+ var isGlobalAttribution = (options) => options.scope === "global" || options.outsideWorktree === "use-global" && detectWorktreeRoot(options.directory) === void 0;
1820
1821
 
1821
1822
  // src/attribution/is-global-choice/is-global-choice.ts
1822
1823
  var isGlobalChoice = (attribution) => attribution.kind === "personal" && attribution.boundKeyId === void 0;
@@ -3502,10 +3503,11 @@ var Route33Runtime = class {
3502
3503
  }
3503
3504
  /**
3504
3505
  * Reads the stored key for a saved attribution without any login.
3506
+ * @param state - Whose attribution to read; this folder's by default.
3505
3507
  * @returns The reusable key and lease when the stored lease is still valid.
3506
3508
  */
3507
- async storedReusableKey() {
3508
- const attribution = readAttribution(this.#options.state);
3509
+ async storedReusableKey(state = this.#options.state) {
3510
+ const attribution = readAttribution(state);
3509
3511
  if (attribution === void 0) {
3510
3512
  return void 0;
3511
3513
  }
@@ -3672,10 +3674,11 @@ var Route33Runtime = class {
3672
3674
  * @param extras - The wizard's key-creation answers.
3673
3675
  * @param directory - Optional worktree override for project leases.
3674
3676
  * @param saveAttribution - Wizard save that must succeed before replacing a live key.
3677
+ * @param state - Where that save lands; the directory's own state by default.
3675
3678
  * @returns The fresh key material with its lease metadata.
3676
3679
  */
3677
- async mintWorkspaceKey(attribution, extras, directory = this.#options.state.directory, saveAttribution) {
3678
- const file = resolveAttributionFile({ ...this.#options.state, directory });
3680
+ async mintWorkspaceKey(attribution, extras, directory = this.#options.state.directory, saveAttribution, state = { ...this.#options.state, directory }) {
3681
+ const file = resolveAttributionFile(state);
3679
3682
  if (file === void 0)
3680
3683
  throw new TypeError("Workspace attribution requires a worktree");
3681
3684
  const previous = statSync2(file, { bigint: true, throwIfNoEntry: false });
@@ -5169,6 +5172,11 @@ var createConnectAuthorize = (deps) => async (answer = {}) => {
5169
5172
  };
5170
5173
  };
5171
5174
 
5175
+ // src/v2-entry/global-key-answer/global-key-answer.ts
5176
+ var ATTRIBUTION_SCOPE_FIELD_KEY = "attribution_scope";
5177
+ var GLOBAL_KEY_ANSWER = { [ATTRIBUTION_SCOPE_FIELD_KEY]: "global" };
5178
+ var isGlobalKeyAnswer = (answer) => answer[ATTRIBUTION_SCOPE_FIELD_KEY] === "global";
5179
+
5172
5180
  // src/v2-entry/connect-form/budget-question-copy/budget-question-copy.ts
5173
5181
  var budgetQuestionCopy = (plan) => plan.notice === void 0 ? {
5174
5182
  attribution: {
@@ -5183,9 +5191,42 @@ var budgetQuestionCopy = (plan) => plan.notice === void 0 ? {
5183
5191
  organisation: "Which Route 33 organisation covers folders outside Git?"
5184
5192
  };
5185
5193
 
5186
- // src/v2-entry/connect-form/connect-form.ts
5187
- var ATTRIBUTION_FIELD_KEY2 = "attribution";
5194
+ // src/v2-entry/connect-form/budget-fields/budget-fields.ts
5188
5195
  var ORGANISATION_FIELD_KEY = "organisation";
5196
+ var budgetFields = (plan) => {
5197
+ const orgs = plan.orgs ?? [];
5198
+ const copy = budgetQuestionCopy(plan);
5199
+ const organisationFields = orgs.length > 1 ? [
5200
+ {
5201
+ key: ORGANISATION_FIELD_KEY,
5202
+ options: orgs.map(({ id, name }) => ({ label: name, value: id })),
5203
+ title: copy.organisation,
5204
+ type: "string"
5205
+ }
5206
+ ] : [];
5207
+ const attributionField = {
5208
+ ...copy.attribution,
5209
+ key: ATTRIBUTION_FIELD_KEY,
5210
+ options: plan.options.map((option) => ({
5211
+ label: option.label,
5212
+ value: option.selection
5213
+ })),
5214
+ // Deliberately not required: the boot session probe connects without
5215
+ // an answer — a required field makes the host reject bare connects
5216
+ // (400 Missing required form field) and kills the probe. The wizard
5217
+ // still sends the attribution on its answer pass.
5218
+ type: "string"
5219
+ };
5220
+ const scopeFields = plan.notice === void 0 ? [{ hidden: true, key: ATTRIBUTION_SCOPE_FIELD_KEY, type: "string" }] : [];
5221
+ const [first = attributionField, ...rest] = [
5222
+ ...organisationFields,
5223
+ attributionField,
5224
+ ...scopeFields
5225
+ ];
5226
+ return [first, ...rest];
5227
+ };
5228
+
5229
+ // src/v2-entry/connect-form/connect-form.ts
5189
5230
  var BUDGET_NAME_FIELD_KEY = "budget_name";
5190
5231
  var BUDGET_CAP_FIELD_KEY = "budget_cap";
5191
5232
  var BUDGET_CAP_MAX_FIELD_KEY = "budget_cap_max";
@@ -5204,29 +5245,8 @@ var EXPIRY_OPTIONS = [
5204
5245
  ];
5205
5246
  var buildConnectForm = (plan, key) => {
5206
5247
  const maximum = key?.maximum;
5207
- const orgs = plan.orgs ?? [];
5208
- const copy = budgetQuestionCopy(plan);
5209
- const organisationField = {
5210
- key: ORGANISATION_FIELD_KEY,
5211
- options: orgs.map(({ id, name }) => ({ label: name, value: id })),
5212
- title: copy.organisation,
5213
- type: "string"
5214
- };
5215
- const attributionField = {
5216
- ...copy.attribution,
5217
- key: ATTRIBUTION_FIELD_KEY2,
5218
- options: plan.options.map((option) => ({
5219
- label: option.label,
5220
- value: option.selection
5221
- })),
5222
- // Deliberately not required: the boot session probe connects without
5223
- // an answer — a required field makes the host reject bare connects
5224
- // (400 Missing required form field) and kills the probe. The wizard
5225
- // still sends the attribution on its answer pass.
5226
- type: "string"
5227
- };
5228
- const budgetFields = orgs.length > 1 ? [organisationField, attributionField] : [attributionField];
5229
- if (key === void 0) return budgetFields;
5248
+ const fields = budgetFields(plan);
5249
+ if (key === void 0) return fields;
5230
5250
  const promptFields = [
5231
5251
  {
5232
5252
  key: BUDGET_NAME_FIELD_KEY,
@@ -5281,7 +5301,7 @@ var buildConnectForm = (plan, key) => {
5281
5301
  type: "string"
5282
5302
  });
5283
5303
  return [
5284
- ...budgetFields,
5304
+ ...fields,
5285
5305
  ...promptFields,
5286
5306
  ...maximum === void 0 ? [] : [helper(BUDGET_CAP_MAX_FIELD_KEY, String(maximum))],
5287
5307
  ...key.prepared === void 0 ? [] : [helper(PREPARED_BUDGET_FIELD_KEY, key.prepared)]
@@ -5307,6 +5327,155 @@ var directKeyMode = async (context, options, compose) => {
5307
5327
  };
5308
5328
  };
5309
5329
 
5330
+ // src/v2-entry/resolve-host-credential/resolve-host-credential.ts
5331
+ 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.";
5332
+ var resolveHostCredential = async (deps) => {
5333
+ await deps.config();
5334
+ deps.onProvider(deps.parseProvider(void 0));
5335
+ const active = deps.runtime();
5336
+ const stored = await active?.storedReusableKey();
5337
+ if (stored === void 0) {
5338
+ throw new GatewayCredentialError(NO_USABLE_LEASE_MESSAGE);
5339
+ }
5340
+ await deps.reloadProviders();
5341
+ return {
5342
+ access: stored.key.value,
5343
+ expires: Date.parse(stored.lease.expiresAt),
5344
+ methodID: deps.methodID,
5345
+ refresh: stored.lease.keyId,
5346
+ type: "oauth"
5347
+ };
5348
+ };
5349
+
5350
+ // src/v2-entry/binding-fields/binding-fields.ts
5351
+ var bindingFields = async (plan, binding) => {
5352
+ const confirmations = /* @__PURE__ */ new Map();
5353
+ const fields = [];
5354
+ for (const [selection, choice] of Object.entries(plan.choicesBySelection)) {
5355
+ const keys = await binding.candidates(choice);
5356
+ if (!keys.length) continue;
5357
+ for (const key of keys) if (!key.local) confirmations.set(key.id, key.name);
5358
+ fields.push({
5359
+ key: `existing_key:${selection}`,
5360
+ type: "string",
5361
+ title: "Which key should this folder use?",
5362
+ options: [
5363
+ { label: "Mint a new key", value: "new" },
5364
+ ...keys.map((key) => ({
5365
+ label: `Bind ${key.name} (${key.id})`,
5366
+ value: key.id
5367
+ }))
5368
+ ]
5369
+ });
5370
+ }
5371
+ if (confirmations.size)
5372
+ fields.push({
5373
+ key: "rotation_confirmation",
5374
+ type: "string",
5375
+ title: ROTATION_WARNING,
5376
+ options: [
5377
+ { label: "No", value: "no" },
5378
+ ...Array.from(confirmations, ([id, name]) => ({
5379
+ label: `Yes, rotate ${name} (${id})`,
5380
+ value: id
5381
+ }))
5382
+ ]
5383
+ });
5384
+ return fields;
5385
+ };
5386
+
5387
+ // src/v2-entry/selected-budget-form/read-model-choices/read-model-choices.ts
5388
+ var FORBIDDEN = 403;
5389
+ var readModelChoices = async (read) => {
5390
+ try {
5391
+ return { models: await read() };
5392
+ } catch (cause) {
5393
+ return {
5394
+ models: [],
5395
+ modelsNote: cause instanceof ManagementError && cause.statusCode === FORBIDDEN ? KEY_FORM_COPY.modelsNeedSignIn : KEY_FORM_COPY.modelsUnavailable
5396
+ };
5397
+ }
5398
+ };
5399
+
5400
+ // src/v2-entry/selected-budget-form/selected-budget-form.ts
5401
+ var selectedBudgetForm = async (plan, selection, runtime2) => {
5402
+ const option = plan.options.find((row) => row.selection === selection);
5403
+ const choice = plan.choicesBySelection[selection];
5404
+ if (!option || !choice)
5405
+ throw new GatewayCredentialError(CONNECT_COPY.selectionInvalid);
5406
+ const scoped = {
5407
+ title: plan.title,
5408
+ options: [option],
5409
+ choicesBySelection: { [selection]: choice }
5410
+ };
5411
+ const choices = await readModelChoices(
5412
+ () => runtime2.catalogModelChoices(choice)
5413
+ );
5414
+ const keys = await bindingFields(scoped, await runtime2.workspaceKeyBinding());
5415
+ return [
5416
+ ...buildConnectForm(plan, {
5417
+ ...choices,
5418
+ ...option.maximum === void 0 ? {} : { maximum: option.maximum },
5419
+ prepared: selection
5420
+ }),
5421
+ ...keys
5422
+ ];
5423
+ };
5424
+
5425
+ // src/v2-entry/global-key-authorize/global-key-authorize.ts
5426
+ var createGlobalKeyAuthorize = (deps) => {
5427
+ const state = {
5428
+ directory: deps.directory,
5429
+ outsideWorktree: "use-global",
5430
+ scope: "global"
5431
+ };
5432
+ const runtime2 = () => {
5433
+ const active = deps.getRuntime();
5434
+ if (active === void 0) {
5435
+ throw new GatewayCredentialError(
5436
+ "Route 33 authorization is unavailable in this host"
5437
+ );
5438
+ }
5439
+ return active;
5440
+ };
5441
+ return createConnectAuthorize({
5442
+ clientId: deps.clientId,
5443
+ getPlan: deps.getPlan,
5444
+ getRuntime: deps.getRuntime,
5445
+ mintWorkspaceKey: async (attribution, extras, save) => runtime2().mintWorkspaceKey(attribution, extras, void 0, save, state),
5446
+ prepareBudget: async (selection, answer) => {
5447
+ const marker = `global:${selection}`;
5448
+ if (deps.form.answers(marker, answer)) return false;
5449
+ const plan = deps.getPlan();
5450
+ const choice = plan?.choicesBySelection[selection];
5451
+ if (!plan || !choice || !isGlobalChoice(choice)) {
5452
+ throw new GatewayCredentialError(CONNECT_COPY.selectionInvalid);
5453
+ }
5454
+ const active = runtime2();
5455
+ const fields = await selectedBudgetForm(plan, selection, {
5456
+ catalogModelChoices: (scope) => active.catalogModelChoices(scope),
5457
+ // A bound key is held per worktree: the global key is always new.
5458
+ workspaceKeyBinding: () => Promise.resolve({ candidates: () => Promise.resolve([]) })
5459
+ });
5460
+ await deps.form.register(fields, marker);
5461
+ return true;
5462
+ },
5463
+ registerProjectForm: deps.registerProjectForm,
5464
+ resolveCredential: () => resolveHostCredential({
5465
+ config: () => Promise.resolve(),
5466
+ methodID: deps.methodID,
5467
+ onProvider: () => void 0,
5468
+ parseProvider: () => void 0,
5469
+ reloadProviders: () => Promise.resolve(),
5470
+ runtime: () => ({
5471
+ storedReusableKey: () => runtime2().storedReusableKey(state)
5472
+ })
5473
+ }),
5474
+ stash: deps.stash,
5475
+ state
5476
+ });
5477
+ };
5478
+
5310
5479
  // src/v2-entry/host-lease-state-store/host-lease-state-store.ts
5311
5480
  var hostLeaseStateStore = (options) => ({
5312
5481
  // The box envelope keeps the server part's writes readable from the
@@ -5361,6 +5530,27 @@ var hostTokenStore = (options) => {
5361
5530
  };
5362
5531
  };
5363
5532
 
5533
+ // src/v2-entry/prepared-form/prepared-form.ts
5534
+ var SELECTION_KEYS = [
5535
+ ATTRIBUTION_FIELD_KEY,
5536
+ ATTRIBUTION_SCOPE_FIELD_KEY
5537
+ ];
5538
+ var createPreparedForm = (reload) => {
5539
+ let registered;
5540
+ let prepared;
5541
+ return {
5542
+ answers: (marker, answer) => prepared === marker && registered?.some(
5543
+ (field) => !SELECTION_KEYS.includes(field.key) && Object.hasOwn(answer, field.key)
5544
+ ) === true,
5545
+ fields: () => registered,
5546
+ register: async (fields, marker) => {
5547
+ registered = fields;
5548
+ prepared = marker;
5549
+ await reload();
5550
+ }
5551
+ };
5552
+ };
5553
+
5364
5554
  // src/v2-entry/model-gate-notify-from/model-gate-notify-from.ts
5365
5555
  var notifyFrom = async (session, sessionID, message) => {
5366
5556
  await session.synthetic?.({ delivery: "queue", sessionID, text: message });
@@ -5591,101 +5781,6 @@ var registerSessionRpc = (rpc, deps) => rpc.register(ROUTE33_SESSION_RPC, {
5591
5781
  }
5592
5782
  });
5593
5783
 
5594
- // src/v2-entry/resolve-host-credential/resolve-host-credential.ts
5595
- 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.";
5596
- var resolveHostCredential = async (deps) => {
5597
- await deps.config();
5598
- deps.onProvider(deps.parseProvider(void 0));
5599
- const active = deps.runtime();
5600
- const stored = await active?.storedReusableKey();
5601
- if (stored === void 0) {
5602
- throw new GatewayCredentialError(NO_USABLE_LEASE_MESSAGE);
5603
- }
5604
- await deps.reloadProviders();
5605
- return {
5606
- access: stored.key.value,
5607
- expires: Date.parse(stored.lease.expiresAt),
5608
- methodID: deps.methodID,
5609
- refresh: stored.lease.keyId,
5610
- type: "oauth"
5611
- };
5612
- };
5613
-
5614
- // src/v2-entry/binding-fields/binding-fields.ts
5615
- var bindingFields = async (plan, binding) => {
5616
- const confirmations = /* @__PURE__ */ new Map();
5617
- const fields = [];
5618
- for (const [selection, choice] of Object.entries(plan.choicesBySelection)) {
5619
- const keys = await binding.candidates(choice);
5620
- if (!keys.length) continue;
5621
- for (const key of keys) if (!key.local) confirmations.set(key.id, key.name);
5622
- fields.push({
5623
- key: `existing_key:${selection}`,
5624
- type: "string",
5625
- title: "Which key should this folder use?",
5626
- options: [
5627
- { label: "Mint a new key", value: "new" },
5628
- ...keys.map((key) => ({
5629
- label: `Bind ${key.name} (${key.id})`,
5630
- value: key.id
5631
- }))
5632
- ]
5633
- });
5634
- }
5635
- if (confirmations.size)
5636
- fields.push({
5637
- key: "rotation_confirmation",
5638
- type: "string",
5639
- title: ROTATION_WARNING,
5640
- options: [
5641
- { label: "No", value: "no" },
5642
- ...Array.from(confirmations, ([id, name]) => ({
5643
- label: `Yes, rotate ${name} (${id})`,
5644
- value: id
5645
- }))
5646
- ]
5647
- });
5648
- return fields;
5649
- };
5650
-
5651
- // src/v2-entry/selected-budget-form/read-model-choices/read-model-choices.ts
5652
- var FORBIDDEN = 403;
5653
- var readModelChoices = async (read) => {
5654
- try {
5655
- return { models: await read() };
5656
- } catch (cause) {
5657
- return {
5658
- models: [],
5659
- modelsNote: cause instanceof ManagementError && cause.statusCode === FORBIDDEN ? KEY_FORM_COPY.modelsNeedSignIn : KEY_FORM_COPY.modelsUnavailable
5660
- };
5661
- }
5662
- };
5663
-
5664
- // src/v2-entry/selected-budget-form/selected-budget-form.ts
5665
- var selectedBudgetForm = async (plan, selection, runtime2) => {
5666
- const option = plan.options.find((row) => row.selection === selection);
5667
- const choice = plan.choicesBySelection[selection];
5668
- if (!option || !choice)
5669
- throw new GatewayCredentialError(CONNECT_COPY.selectionInvalid);
5670
- const scoped = {
5671
- title: plan.title,
5672
- options: [option],
5673
- choicesBySelection: { [selection]: choice }
5674
- };
5675
- const choices = await readModelChoices(
5676
- () => runtime2.catalogModelChoices(choice)
5677
- );
5678
- const keys = await bindingFields(scoped, await runtime2.workspaceKeyBinding());
5679
- return [
5680
- ...buildConnectForm(plan, {
5681
- ...choices,
5682
- ...option.maximum === void 0 ? {} : { maximum: option.maximum },
5683
- prepared: selection
5684
- }),
5685
- ...keys
5686
- ];
5687
- };
5688
-
5689
5784
  // src/v2-entry/is-account-removed/is-account-removed.ts
5690
5785
  var isAccountRemoved = (event) => {
5691
5786
  if (!isRecord(event) || event["type"] !== "credential.switched") return false;
@@ -5738,6 +5833,7 @@ var createWorkspaceKeyHook = (deps) => async (input) => {
5738
5833
  };
5739
5834
 
5740
5835
  // src/v2-entry/create-route33-v2-plugin/create-route33-v2-plugin.ts
5836
+ var ACCOUNT_LABEL = "Route 33";
5741
5837
  var createRoute33V2Plugin = (options = {}) => {
5742
5838
  const clientId2 = options.clientId ?? readEnvClientId() ?? DEFAULT_ROUTE33_CLIENT_ID;
5743
5839
  const issuerUrl2 = options.issuerUrl ?? readEnvAuthIssuer() ?? DEFAULT_AUTH_ISSUER_URL;
@@ -5769,9 +5865,8 @@ var createRoute33V2Plugin = (options = {}) => {
5769
5865
  });
5770
5866
  let runtime2;
5771
5867
  let provider = mapRoute33V2Provider(void 0);
5772
- let connectFields;
5773
5868
  let plan;
5774
- let preparedBudget;
5869
+ const form = createPreparedForm(() => context.integration.reload());
5775
5870
  const runtimeInput = {
5776
5871
  ...options.runtime ?? buildProductionRuntimeOptions({
5777
5872
  apiBaseUrl,
@@ -5812,17 +5907,14 @@ var createRoute33V2Plugin = (options = {}) => {
5812
5907
  activeRuntime.listMintableOrgs({ allowBrowser: false }).catch(() => void 0),
5813
5908
  activeRuntime.hasPersonalLease().catch(() => false)
5814
5909
  ]);
5815
- preparedBudget = void 0;
5816
5910
  if (mintableOrgs === void 0) {
5817
5911
  plan = void 0;
5818
- connectFields = void 0;
5819
- await context.integration.reload();
5912
+ await form.register(void 0);
5820
5913
  return;
5821
5914
  }
5822
5915
  const orgs = mintableOrgs;
5823
5916
  plan = attributionPlan({ global, orgs, personalKeyActive });
5824
- connectFields = buildConnectForm(plan);
5825
- await context.integration.reload();
5917
+ await form.register(buildConnectForm(plan));
5826
5918
  };
5827
5919
  const authorize = createConnectAuthorize({
5828
5920
  clientId: clientId2,
@@ -5840,15 +5932,11 @@ var createRoute33V2Plugin = (options = {}) => {
5840
5932
  return active.mintWorkspaceKey(attribution, extras, void 0, save);
5841
5933
  },
5842
5934
  prepareBudget: async (selection, answer) => {
5843
- if (preparedBudget === selection && connectFields?.some(
5844
- (field) => field.key !== "attribution" && Object.hasOwn(answer, field.key)
5845
- ) === true)
5846
- return false;
5935
+ if (form.answers(selection, answer)) return false;
5847
5936
  if (!runtime2 || !plan)
5848
5937
  throw new GatewayCredentialError(CONNECT_COPY.selectionInvalid);
5849
- connectFields = await selectedBudgetForm(plan, selection, runtime2);
5850
- preparedBudget = selection;
5851
- await context.integration.reload();
5938
+ const fields = await selectedBudgetForm(plan, selection, runtime2);
5939
+ await form.register(fields, selection);
5852
5940
  return true;
5853
5941
  },
5854
5942
  registerProjectForm,
@@ -5856,19 +5944,34 @@ var createRoute33V2Plugin = (options = {}) => {
5856
5944
  stash,
5857
5945
  state
5858
5946
  });
5947
+ const authorizeGlobalKey = createGlobalKeyAuthorize({
5948
+ clientId: clientId2,
5949
+ directory: context.location.directory,
5950
+ form,
5951
+ getPlan: () => plan,
5952
+ getRuntime: () => runtime2,
5953
+ methodID,
5954
+ registerProjectForm,
5955
+ stash
5956
+ });
5859
5957
  const providerTransform = await context.provider.transform((editor) => {
5860
5958
  editor.add(provider);
5861
5959
  });
5862
5960
  const integrationTransform = await context.integration.transform(
5863
5961
  (editor) => {
5864
5962
  editor.method.update({
5865
- authorize: (answer) => authorize(answer),
5963
+ authorize: (answer) => (isGlobalKeyAnswer(answer) ? authorizeGlobalKey : authorize)(
5964
+ answer
5965
+ ),
5866
5966
  integrationID: "route33",
5967
+ // One name for the one account: unnamed, the host numbers each
5968
+ // new account after the ones it already holds.
5969
+ label: () => ACCOUNT_LABEL,
5867
5970
  method: {
5868
5971
  id: methodID,
5869
5972
  label: TRUSTED_PARTY_COPY.title,
5870
5973
  type: "oauth",
5871
- ...connectFields === void 0 ? {} : { form: connectFields }
5974
+ ...form.fields() === void 0 ? {} : { form: form.fields() }
5872
5975
  },
5873
5976
  refresh: () => resolveCredential()
5874
5977
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r-33/opencode",
3
- "version": "0.5.1-rc.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",