@tokenbuddy/tokenbuddy 1.0.38 → 1.0.39

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/src/cli.js CHANGED
@@ -696,6 +696,33 @@ function stableModelChoices(models) {
696
696
  };
697
697
  });
698
698
  }
699
+ const OPENCODE_SUPPORTED_PROTOCOLS = ["chat_completions", "responses", "messages"];
700
+ function uniqueModelIds(models) {
701
+ const seen = new Set();
702
+ const output = [];
703
+ for (const model of models) {
704
+ const trimmed = model.trim();
705
+ if (!trimmed || seen.has(trimmed)) {
706
+ continue;
707
+ }
708
+ seen.add(trimmed);
709
+ output.push(trimmed);
710
+ }
711
+ return output;
712
+ }
713
+ function availableModelsByProtocol(models, protocols) {
714
+ const result = {};
715
+ for (const protocol of protocols) {
716
+ const modelIds = uniqueModelIds(filterCatalogByProtocol(models, protocol).map((entry) => entry.id));
717
+ if (modelIds.length > 0) {
718
+ result[protocol] = modelIds;
719
+ }
720
+ }
721
+ return result;
722
+ }
723
+ function filterCatalogByAnyProtocol(models, protocols) {
724
+ return models.filter((entry) => protocols.some((protocol) => entry.supportedProtocols.includes(protocol)));
725
+ }
699
726
  async function promptSellerRoutingPreference(catalog) {
700
727
  const healthySellers = catalog.sellers.filter((seller) => seller.status === "ok");
701
728
  const mode = await p.select({
@@ -860,6 +887,28 @@ async function promptSingleModelSelection(providerId, models) {
860
887
  selectionKind: "single-model",
861
888
  protocolPreference,
862
889
  defaultModel: selectedModel,
890
+ ...(protocolPreference ? {
891
+ availableModelsByProtocol: availableModelsByProtocol(models, [protocolPreference]),
892
+ } : {}),
893
+ };
894
+ }
895
+ async function promptOpenCodeModelSelection(models) {
896
+ const compatibleModels = filterCatalogByAnyProtocol(models, OPENCODE_SUPPORTED_PROTOCOLS);
897
+ const choices = stableModelChoices(compatibleModels);
898
+ if (choices.length === 0) {
899
+ throw new Error("no compatible models available for OpenCode");
900
+ }
901
+ const selectedModel = await p.select({
902
+ message: "Choose the default model for OpenCode:",
903
+ options: choices,
904
+ });
905
+ if (typeof selectedModel !== "string") {
906
+ throw new Error("default model selection was cancelled for OpenCode");
907
+ }
908
+ return {
909
+ selectionKind: "single-model",
910
+ defaultModel: selectedModel,
911
+ availableModelsByProtocol: availableModelsByProtocol(models, OPENCODE_SUPPORTED_PROTOCOLS),
863
912
  };
864
913
  }
865
914
  function defaultClaudeDisplayName(modelId) {
@@ -958,6 +1007,10 @@ async function promptProviderSelections(providerIds, catalog, sellerRouting) {
958
1007
  : catalog.models;
959
1008
  const selections = {};
960
1009
  for (const providerId of providerIds) {
1010
+ if (providerId === "opencode") {
1011
+ selections[providerId] = await promptOpenCodeModelSelection(baseModels);
1012
+ continue;
1013
+ }
961
1014
  const selectionKind = getProviderModelSelectionKind(providerId);
962
1015
  if (selectionKind === "claude-role-mapping") {
963
1016
  selections[providerId] = await promptClaudeCodeModelSelection(baseModels);
@@ -24,11 +24,7 @@ export interface DaemonConfig {
24
24
  /** test-only override for the existing tb init ClawTip activation runner. */
25
25
  clawtipWalletBootstrapStarter?: (payment: ClawtipBootstrapPayment, options?: {
26
26
  home?: string;
27
- }) => Promise<{
28
- orderFile: string;
29
- parsedOutput: ParsedClawtipOutput;
30
- payCredential?: string;
31
- }>;
27
+ }) => Promise<ClawtipActivationResult>;
32
28
  /** test-only override for waiting on the existing tb init ClawTip registration loop. */
33
29
  clawtipActivationWaiter?: (options?: WaitForClawtipActivationOptions) => Promise<boolean>;
34
30
  /** test-only override for bundled ClawTip static assets; false disables bundled assets. */
@@ -93,6 +89,7 @@ export declare class TokenbuddyDaemon {
93
89
  private ensureClawtipStaticAssets;
94
90
  private copyClawtipQrToStatic;
95
91
  private startClawtipActivationQr;
92
+ private startClawtipActivationWithRebindFallback;
96
93
  private scheduleClawtipActivationWait;
97
94
  private clawtipRechargeQr;
98
95
  private lastRegistrySnapshot;
@@ -130,6 +127,21 @@ export declare class TokenbuddyDaemon {
130
127
  private applyAutoProviderRoutingConfig;
131
128
  private autoProviderCanRoute;
132
129
  private providerModePayload;
130
+ private isReconnectProviderId;
131
+ private uniqueModelIds;
132
+ private reconnectProtocolForProvider;
133
+ private reconnectProtocolsForProvider;
134
+ private catalogModelSupportsProtocol;
135
+ private catalogModelsByProtocol;
136
+ private previousProviderDefaultModel;
137
+ private pickReconnectDefaultModel;
138
+ private reconnectProviderSelection;
139
+ private reconnectProviderSelections;
140
+ private manualProviderModelCatalog;
141
+ private discoverSellerModelCatalog;
142
+ private refreshEnabledManualProviderModels;
143
+ private filterAutoEffectiveCatalog;
144
+ private effectiveModelCatalog;
133
145
  private clientToolsSummary;
134
146
  private initRepairStatus;
135
147
  private initStateSnapshot;
@@ -270,4 +282,10 @@ export declare class TokenbuddyDaemon {
270
282
  */
271
283
  setLastRegistrySnapshotForTest(snapshot: SellerRegistryDocument | null): void;
272
284
  }
285
+ interface ClawtipActivationResult {
286
+ orderFile: string;
287
+ parsedOutput: ParsedClawtipOutput;
288
+ payCredential?: string;
289
+ }
290
+ export {};
273
291
  //# sourceMappingURL=daemon.d.ts.map