@bizzywork/routing 0.1.0 → 0.2.0

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.
@@ -3,54 +3,14 @@ import { fileURLToPath as __bizzyPath } from "node:url";
3
3
  const require = __bizzyRequire(import.meta.url);
4
4
  const __filename = __bizzyPath(import.meta.url);
5
5
  const __dirname = __bizzyPath(new URL(".", import.meta.url));
6
- var __create = Object.create;
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
13
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
14
- }) : x)(function(x) {
15
- if (typeof require !== "undefined") return require.apply(this, arguments);
16
- throw Error('Dynamic require of "' + x + '" is not supported');
17
- });
18
- var __esm = (fn, res, err) => function __init() {
19
- if (err) throw err[0];
20
- try {
21
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
22
- } catch (e) {
23
- throw err = [e], e;
24
- }
25
- };
26
- var __commonJS = (cb, mod) => function __require2() {
27
- try {
28
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
29
- } catch (e) {
30
- throw mod = 0, e;
31
- }
32
- };
33
- var __export = (target, all) => {
34
- for (var name in all)
35
- __defProp(target, name, { get: all[name], enumerable: true });
36
- };
37
- var __copyProps = (to, from, except, desc) => {
38
- if (from && typeof from === "object" || typeof from === "function") {
39
- for (let key of __getOwnPropNames(from))
40
- if (!__hasOwnProp.call(to, key) && key !== except)
41
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
- }
43
- return to;
44
- };
45
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
46
- // If the importer is in node compatibility mode or this is not an ESM
47
- // file that has been converted to a CommonJS file using a Babel-
48
- // compatible transform (i.e. "__esModule" has not been set), then set
49
- // "default" to the CommonJS "module.exports" for node compatibility.
50
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
51
- mod
52
- ));
53
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
6
+ import {
7
+ __commonJS,
8
+ __esm,
9
+ __export,
10
+ __require,
11
+ __toCommonJS,
12
+ __toESM
13
+ } from "./chunk-RYVRLJBJ.js";
54
14
 
55
15
  // node_modules/fastify-plugin/lib/getPluginName.js
56
16
  var require_getPluginName = __commonJS({
@@ -9202,8 +9162,8 @@ var require_common = __commonJS({
9202
9162
  }
9203
9163
  return debug;
9204
9164
  }
9205
- function extend2(namespace, delimiter) {
9206
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
9165
+ function extend2(namespace, delimiter2) {
9166
+ const newDebug = createDebug(this.namespace + (typeof delimiter2 === "undefined" ? ":" : delimiter2) + namespace);
9207
9167
  newDebug.log = this.log;
9208
9168
  return newDebug;
9209
9169
  }
@@ -10003,11 +9963,11 @@ var require_definitions = __commonJS({
10003
9963
  walkSchema(value, visit2, pointer, baseId, baseDepth);
10004
9964
  pointer.pop();
10005
9965
  } else if (SCHEMA_MAP_KEYWORDS2.has(key) && isObject2(value)) {
10006
- const names = Object.keys(value);
9966
+ const names2 = Object.keys(value);
10007
9967
  pointer.push(key);
10008
- for (let j = 0; j < names.length; j++) {
10009
- pointer.push(names[j]);
10010
- walkSchema(value[names[j]], visit2, pointer, baseId, baseDepth);
9968
+ for (let j = 0; j < names2.length; j++) {
9969
+ pointer.push(names2[j]);
9970
+ walkSchema(value[names2[j]], visit2, pointer, baseId, baseDepth);
10011
9971
  pointer.pop();
10012
9972
  }
10013
9973
  pointer.pop();
@@ -16053,7 +16013,7 @@ var require_send = __commonJS({
16053
16013
  var { parseTokenList } = require_parseTokenList();
16054
16014
  var { createHttpError } = require_createHttpError();
16055
16015
  var extname = path.extname;
16056
- var join11 = path.join;
16016
+ var join12 = path.join;
16057
16017
  var normalize = path.normalize;
16058
16018
  var resolve3 = path.resolve;
16059
16019
  var sep = path.sep;
@@ -16148,7 +16108,7 @@ var require_send = __commonJS({
16148
16108
  return { statusCode: 403 };
16149
16109
  }
16150
16110
  parts = path2.split(sep);
16151
- path2 = normalize(join11(root, path2));
16111
+ path2 = normalize(join12(root, path2));
16152
16112
  } else {
16153
16113
  if (UP_PATH_REGEXP.test(path2)) {
16154
16114
  debug('malicious path "%s"', path2);
@@ -16434,7 +16394,7 @@ var require_send = __commonJS({
16434
16394
  let err;
16435
16395
  for (let i = 0; i < options.index.length; i++) {
16436
16396
  const index = options.index[i];
16437
- const p = join11(path2, index);
16397
+ const p = join12(path2, index);
16438
16398
  const { error: error62, stat } = await tryStat(p);
16439
16399
  if (error62) {
16440
16400
  err = error62;
@@ -25960,7 +25920,7 @@ var require_on_exit_leak_free = __commonJS({
25960
25920
  registry3 = new FinalizationRegistry(clear);
25961
25921
  }
25962
25922
  }
25963
- function install2(event) {
25923
+ function install(event) {
25964
25924
  if (refs[event].length > 0) {
25965
25925
  return;
25966
25926
  }
@@ -26002,7 +25962,7 @@ var require_on_exit_leak_free = __commonJS({
26002
25962
  if (obj === void 0) {
26003
25963
  throw new Error("the object can't be undefined");
26004
25964
  }
26005
- install2(event);
25965
+ install(event);
26006
25966
  const ref2 = new WeakRef(obj);
26007
25967
  ref2.fn = fn;
26008
25968
  ensureRegistry();
@@ -26173,7 +26133,7 @@ var require_thread_stream = __commonJS({
26173
26133
  var { version: version2 } = require_package();
26174
26134
  var { EventEmitter } = __require("events");
26175
26135
  var { Worker } = __require("worker_threads");
26176
- var { join: join11 } = __require("path");
26136
+ var { join: join12 } = __require("path");
26177
26137
  var { pathToFileURL } = __require("url");
26178
26138
  var { wait } = require_wait();
26179
26139
  var {
@@ -26224,7 +26184,7 @@ var require_thread_stream = __commonJS({
26224
26184
  function createWorker(stream, opts) {
26225
26185
  const { filename, workerData } = opts;
26226
26186
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
26227
- const toExecute = bundlerOverrides["thread-stream-worker"] || join11(__dirname, "lib", "worker.js");
26187
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join12(__dirname, "lib", "worker.js");
26228
26188
  const worker = new Worker(toExecute, {
26229
26189
  ...opts.workerOpts,
26230
26190
  name: opts.workerOpts?.name || "thread-stream",
@@ -26690,9 +26650,9 @@ var require_transport = __commonJS({
26690
26650
  "node_modules/pino/lib/transport.js"(exports, module) {
26691
26651
  "use strict";
26692
26652
  var { createRequire } = __require("module");
26693
- var { existsSync: existsSync5 } = __require("node:fs");
26653
+ var { existsSync: existsSync6 } = __require("node:fs");
26694
26654
  var getCallers = require_caller();
26695
- var { join: join11, isAbsolute, sep } = __require("node:path");
26655
+ var { join: join12, isAbsolute, sep } = __require("node:path");
26696
26656
  var { fileURLToPath } = __require("node:url");
26697
26657
  var sleep = require_atomic_sleep();
26698
26658
  var onExit = require_on_exit_leak_free();
@@ -26765,7 +26725,7 @@ var require_transport = __commonJS({
26765
26725
  return false;
26766
26726
  }
26767
26727
  }
26768
- return isAbsolute(path) && !existsSync5(path);
26728
+ return isAbsolute(path) && !existsSync6(path);
26769
26729
  }
26770
26730
  function stripQuotes(value) {
26771
26731
  const first = value[0];
@@ -26847,7 +26807,7 @@ var require_transport = __commonJS({
26847
26807
  throw new Error("only one of target or targets can be specified");
26848
26808
  }
26849
26809
  if (targets) {
26850
- target = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
26810
+ target = bundlerOverrides["pino-worker"] || join12(__dirname, "worker.js");
26851
26811
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
26852
26812
  return {
26853
26813
  ...dest,
@@ -26868,7 +26828,7 @@ var require_transport = __commonJS({
26868
26828
  const pipelinesHaveLevel = options.pipelines.some((p) => p.some((t) => t.level != null));
26869
26829
  usesMultistream = options.targets.length + options.pipelines.length > 1 || targetsHaveLevel || pipelinesHaveLevel;
26870
26830
  } else if (pipeline) {
26871
- target = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
26831
+ target = bundlerOverrides["pino-worker"] || join12(__dirname, "worker.js");
26872
26832
  options.pipelines = [pipeline.map((dest) => {
26873
26833
  return {
26874
26834
  ...dest,
@@ -26895,7 +26855,7 @@ var require_transport = __commonJS({
26895
26855
  return origin;
26896
26856
  }
26897
26857
  if (origin === "pino/file") {
26898
- return join11(__dirname, "..", "file.js");
26858
+ return join12(__dirname, "..", "file.js");
26899
26859
  }
26900
26860
  let fixTarget2;
26901
26861
  for (const filePath of callers) {
@@ -27875,7 +27835,7 @@ var require_safe_stable_stringify = __commonJS({
27875
27835
  return circularValue;
27876
27836
  }
27877
27837
  let res = "";
27878
- let join11 = ",";
27838
+ let join12 = ",";
27879
27839
  const originalIndentation = indentation;
27880
27840
  if (Array.isArray(value)) {
27881
27841
  if (value.length === 0) {
@@ -27889,7 +27849,7 @@ var require_safe_stable_stringify = __commonJS({
27889
27849
  indentation += spacer;
27890
27850
  res += `
27891
27851
  ${indentation}`;
27892
- join11 = `,
27852
+ join12 = `,
27893
27853
  ${indentation}`;
27894
27854
  }
27895
27855
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -27897,13 +27857,13 @@ ${indentation}`;
27897
27857
  for (; i < maximumValuesToStringify - 1; i++) {
27898
27858
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
27899
27859
  res += tmp2 !== void 0 ? tmp2 : "null";
27900
- res += join11;
27860
+ res += join12;
27901
27861
  }
27902
27862
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
27903
27863
  res += tmp !== void 0 ? tmp : "null";
27904
27864
  if (value.length - 1 > maximumBreadth) {
27905
27865
  const removedKeys = value.length - maximumBreadth - 1;
27906
- res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
27866
+ res += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
27907
27867
  }
27908
27868
  if (spacer !== "") {
27909
27869
  res += `
@@ -27924,7 +27884,7 @@ ${originalIndentation}`;
27924
27884
  let separator = "";
27925
27885
  if (spacer !== "") {
27926
27886
  indentation += spacer;
27927
- join11 = `,
27887
+ join12 = `,
27928
27888
  ${indentation}`;
27929
27889
  whitespace = " ";
27930
27890
  }
@@ -27938,13 +27898,13 @@ ${indentation}`;
27938
27898
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
27939
27899
  if (tmp !== void 0) {
27940
27900
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
27941
- separator = join11;
27901
+ separator = join12;
27942
27902
  }
27943
27903
  }
27944
27904
  if (keyLength > maximumBreadth) {
27945
27905
  const removedKeys = keyLength - maximumBreadth;
27946
27906
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
27947
- separator = join11;
27907
+ separator = join12;
27948
27908
  }
27949
27909
  if (spacer !== "" && separator.length > 1) {
27950
27910
  res = `
@@ -27985,7 +27945,7 @@ ${originalIndentation}`;
27985
27945
  }
27986
27946
  const originalIndentation = indentation;
27987
27947
  let res = "";
27988
- let join11 = ",";
27948
+ let join12 = ",";
27989
27949
  if (Array.isArray(value)) {
27990
27950
  if (value.length === 0) {
27991
27951
  return "[]";
@@ -27998,7 +27958,7 @@ ${originalIndentation}`;
27998
27958
  indentation += spacer;
27999
27959
  res += `
28000
27960
  ${indentation}`;
28001
- join11 = `,
27961
+ join12 = `,
28002
27962
  ${indentation}`;
28003
27963
  }
28004
27964
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -28006,13 +27966,13 @@ ${indentation}`;
28006
27966
  for (; i < maximumValuesToStringify - 1; i++) {
28007
27967
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
28008
27968
  res += tmp2 !== void 0 ? tmp2 : "null";
28009
- res += join11;
27969
+ res += join12;
28010
27970
  }
28011
27971
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
28012
27972
  res += tmp !== void 0 ? tmp : "null";
28013
27973
  if (value.length - 1 > maximumBreadth) {
28014
27974
  const removedKeys = value.length - maximumBreadth - 1;
28015
- res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
27975
+ res += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
28016
27976
  }
28017
27977
  if (spacer !== "") {
28018
27978
  res += `
@@ -28025,7 +27985,7 @@ ${originalIndentation}`;
28025
27985
  let whitespace = "";
28026
27986
  if (spacer !== "") {
28027
27987
  indentation += spacer;
28028
- join11 = `,
27988
+ join12 = `,
28029
27989
  ${indentation}`;
28030
27990
  whitespace = " ";
28031
27991
  }
@@ -28034,7 +27994,7 @@ ${indentation}`;
28034
27994
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
28035
27995
  if (tmp !== void 0) {
28036
27996
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
28037
- separator = join11;
27997
+ separator = join12;
28038
27998
  }
28039
27999
  }
28040
28000
  if (spacer !== "" && separator.length > 1) {
@@ -28092,20 +28052,20 @@ ${originalIndentation}`;
28092
28052
  indentation += spacer;
28093
28053
  let res2 = `
28094
28054
  ${indentation}`;
28095
- const join12 = `,
28055
+ const join13 = `,
28096
28056
  ${indentation}`;
28097
28057
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
28098
28058
  let i = 0;
28099
28059
  for (; i < maximumValuesToStringify - 1; i++) {
28100
28060
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
28101
28061
  res2 += tmp2 !== void 0 ? tmp2 : "null";
28102
- res2 += join12;
28062
+ res2 += join13;
28103
28063
  }
28104
28064
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
28105
28065
  res2 += tmp !== void 0 ? tmp : "null";
28106
28066
  if (value.length - 1 > maximumBreadth) {
28107
28067
  const removedKeys = value.length - maximumBreadth - 1;
28108
- res2 += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
28068
+ res2 += `${join13}"... ${getItemCount(removedKeys)} not stringified"`;
28109
28069
  }
28110
28070
  res2 += `
28111
28071
  ${originalIndentation}`;
@@ -28121,16 +28081,16 @@ ${originalIndentation}`;
28121
28081
  return '"[Object]"';
28122
28082
  }
28123
28083
  indentation += spacer;
28124
- const join11 = `,
28084
+ const join12 = `,
28125
28085
  ${indentation}`;
28126
28086
  let res = "";
28127
28087
  let separator = "";
28128
28088
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
28129
28089
  if (isTypedArrayWithEntries(value)) {
28130
- res += stringifyTypedArray(value, join11, maximumBreadth);
28090
+ res += stringifyTypedArray(value, join12, maximumBreadth);
28131
28091
  keys = keys.slice(value.length);
28132
28092
  maximumPropertiesToStringify -= value.length;
28133
- separator = join11;
28093
+ separator = join12;
28134
28094
  }
28135
28095
  if (deterministic) {
28136
28096
  keys = sort(keys, comparator);
@@ -28141,13 +28101,13 @@ ${indentation}`;
28141
28101
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
28142
28102
  if (tmp !== void 0) {
28143
28103
  res += `${separator}${strEscape(key2)}: ${tmp}`;
28144
- separator = join11;
28104
+ separator = join12;
28145
28105
  }
28146
28106
  }
28147
28107
  if (keyLength > maximumBreadth) {
28148
28108
  const removedKeys = keyLength - maximumBreadth;
28149
28109
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
28150
- separator = join11;
28110
+ separator = join12;
28151
28111
  }
28152
28112
  if (separator !== "") {
28153
28113
  res = `
@@ -32383,10 +32343,10 @@ var require_code = __commonJS({
32383
32343
  }
32384
32344
  get names() {
32385
32345
  var _a3;
32386
- return (_a3 = this._names) !== null && _a3 !== void 0 ? _a3 : this._names = this._items.reduce((names, c) => {
32346
+ return (_a3 = this._names) !== null && _a3 !== void 0 ? _a3 : this._names = this._items.reduce((names2, c) => {
32387
32347
  if (c instanceof Name)
32388
- names[c.str] = (names[c.str] || 0) + 1;
32389
- return names;
32348
+ names2[c.str] = (names2[c.str] || 0) + 1;
32349
+ return names2;
32390
32350
  }, {});
32391
32351
  }
32392
32352
  };
@@ -32712,11 +32672,11 @@ var require_codegen = __commonJS({
32712
32672
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
32713
32673
  return `${varKind} ${this.name}${rhs};` + _n;
32714
32674
  }
32715
- optimizeNames(names, constants5) {
32716
- if (!names[this.name.str])
32675
+ optimizeNames(names2, constants5) {
32676
+ if (!names2[this.name.str])
32717
32677
  return;
32718
32678
  if (this.rhs)
32719
- this.rhs = optimizeExpr(this.rhs, names, constants5);
32679
+ this.rhs = optimizeExpr(this.rhs, names2, constants5);
32720
32680
  return this;
32721
32681
  }
32722
32682
  get names() {
@@ -32733,15 +32693,15 @@ var require_codegen = __commonJS({
32733
32693
  render({ _n }) {
32734
32694
  return `${this.lhs} = ${this.rhs};` + _n;
32735
32695
  }
32736
- optimizeNames(names, constants5) {
32737
- if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
32696
+ optimizeNames(names2, constants5) {
32697
+ if (this.lhs instanceof code_1.Name && !names2[this.lhs.str] && !this.sideEffects)
32738
32698
  return;
32739
- this.rhs = optimizeExpr(this.rhs, names, constants5);
32699
+ this.rhs = optimizeExpr(this.rhs, names2, constants5);
32740
32700
  return this;
32741
32701
  }
32742
32702
  get names() {
32743
- const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
32744
- return addExprNames(names, this.rhs);
32703
+ const names2 = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
32704
+ return addExprNames(names2, this.rhs);
32745
32705
  }
32746
32706
  };
32747
32707
  var AssignOp = class extends Assign {
@@ -32797,8 +32757,8 @@ var require_codegen = __commonJS({
32797
32757
  optimizeNodes() {
32798
32758
  return `${this.code}` ? this : void 0;
32799
32759
  }
32800
- optimizeNames(names, constants5) {
32801
- this.code = optimizeExpr(this.code, names, constants5);
32760
+ optimizeNames(names2, constants5) {
32761
+ this.code = optimizeExpr(this.code, names2, constants5);
32802
32762
  return this;
32803
32763
  }
32804
32764
  get names() {
@@ -32827,20 +32787,20 @@ var require_codegen = __commonJS({
32827
32787
  }
32828
32788
  return nodes.length > 0 ? this : void 0;
32829
32789
  }
32830
- optimizeNames(names, constants5) {
32790
+ optimizeNames(names2, constants5) {
32831
32791
  const { nodes } = this;
32832
32792
  let i = nodes.length;
32833
32793
  while (i--) {
32834
32794
  const n = nodes[i];
32835
- if (n.optimizeNames(names, constants5))
32795
+ if (n.optimizeNames(names2, constants5))
32836
32796
  continue;
32837
- subtractNames(names, n.names);
32797
+ subtractNames(names2, n.names);
32838
32798
  nodes.splice(i, 1);
32839
32799
  }
32840
32800
  return nodes.length > 0 ? this : void 0;
32841
32801
  }
32842
32802
  get names() {
32843
- return this.nodes.reduce((names, n) => addNames(names, n.names), {});
32803
+ return this.nodes.reduce((names2, n) => addNames(names2, n.names), {});
32844
32804
  }
32845
32805
  };
32846
32806
  var BlockNode = class extends ParentNode {
@@ -32885,20 +32845,20 @@ var require_codegen = __commonJS({
32885
32845
  return void 0;
32886
32846
  return this;
32887
32847
  }
32888
- optimizeNames(names, constants5) {
32848
+ optimizeNames(names2, constants5) {
32889
32849
  var _a3;
32890
- this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants5);
32891
- if (!(super.optimizeNames(names, constants5) || this.else))
32850
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2, constants5);
32851
+ if (!(super.optimizeNames(names2, constants5) || this.else))
32892
32852
  return;
32893
- this.condition = optimizeExpr(this.condition, names, constants5);
32853
+ this.condition = optimizeExpr(this.condition, names2, constants5);
32894
32854
  return this;
32895
32855
  }
32896
32856
  get names() {
32897
- const names = super.names;
32898
- addExprNames(names, this.condition);
32857
+ const names2 = super.names;
32858
+ addExprNames(names2, this.condition);
32899
32859
  if (this.else)
32900
- addNames(names, this.else.names);
32901
- return names;
32860
+ addNames(names2, this.else.names);
32861
+ return names2;
32902
32862
  }
32903
32863
  };
32904
32864
  If.kind = "if";
@@ -32913,10 +32873,10 @@ var require_codegen = __commonJS({
32913
32873
  render(opts) {
32914
32874
  return `for(${this.iteration})` + super.render(opts);
32915
32875
  }
32916
- optimizeNames(names, constants5) {
32917
- if (!super.optimizeNames(names, constants5))
32876
+ optimizeNames(names2, constants5) {
32877
+ if (!super.optimizeNames(names2, constants5))
32918
32878
  return;
32919
- this.iteration = optimizeExpr(this.iteration, names, constants5);
32879
+ this.iteration = optimizeExpr(this.iteration, names2, constants5);
32920
32880
  return this;
32921
32881
  }
32922
32882
  get names() {
@@ -32937,8 +32897,8 @@ var require_codegen = __commonJS({
32937
32897
  return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
32938
32898
  }
32939
32899
  get names() {
32940
- const names = addExprNames(super.names, this.from);
32941
- return addExprNames(names, this.to);
32900
+ const names2 = addExprNames(super.names, this.from);
32901
+ return addExprNames(names2, this.to);
32942
32902
  }
32943
32903
  };
32944
32904
  var ForIter = class extends For {
@@ -32952,10 +32912,10 @@ var require_codegen = __commonJS({
32952
32912
  render(opts) {
32953
32913
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
32954
32914
  }
32955
- optimizeNames(names, constants5) {
32956
- if (!super.optimizeNames(names, constants5))
32915
+ optimizeNames(names2, constants5) {
32916
+ if (!super.optimizeNames(names2, constants5))
32957
32917
  return;
32958
- this.iterable = optimizeExpr(this.iterable, names, constants5);
32918
+ this.iterable = optimizeExpr(this.iterable, names2, constants5);
32959
32919
  return this;
32960
32920
  }
32961
32921
  get names() {
@@ -32997,20 +32957,20 @@ var require_codegen = __commonJS({
32997
32957
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
32998
32958
  return this;
32999
32959
  }
33000
- optimizeNames(names, constants5) {
32960
+ optimizeNames(names2, constants5) {
33001
32961
  var _a3, _b;
33002
- super.optimizeNames(names, constants5);
33003
- (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants5);
33004
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants5);
32962
+ super.optimizeNames(names2, constants5);
32963
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2, constants5);
32964
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names2, constants5);
33005
32965
  return this;
33006
32966
  }
33007
32967
  get names() {
33008
- const names = super.names;
32968
+ const names2 = super.names;
33009
32969
  if (this.catch)
33010
- addNames(names, this.catch.names);
32970
+ addNames(names2, this.catch.names);
33011
32971
  if (this.finally)
33012
- addNames(names, this.finally.names);
33013
- return names;
32972
+ addNames(names2, this.finally.names);
32973
+ return names2;
33014
32974
  }
33015
32975
  };
33016
32976
  var Catch = class extends BlockNode {
@@ -33294,15 +33254,15 @@ var require_codegen = __commonJS({
33294
33254
  }
33295
33255
  };
33296
33256
  exports.CodeGen = CodeGen;
33297
- function addNames(names, from) {
33257
+ function addNames(names2, from) {
33298
33258
  for (const n in from)
33299
- names[n] = (names[n] || 0) + (from[n] || 0);
33300
- return names;
33259
+ names2[n] = (names2[n] || 0) + (from[n] || 0);
33260
+ return names2;
33301
33261
  }
33302
- function addExprNames(names, from) {
33303
- return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
33262
+ function addExprNames(names2, from) {
33263
+ return from instanceof code_1._CodeOrName ? addNames(names2, from.names) : names2;
33304
33264
  }
33305
- function optimizeExpr(expr, names, constants5) {
33265
+ function optimizeExpr(expr, names2, constants5) {
33306
33266
  if (expr instanceof code_1.Name)
33307
33267
  return replaceName(expr);
33308
33268
  if (!canOptimize(expr))
@@ -33318,18 +33278,18 @@ var require_codegen = __commonJS({
33318
33278
  }, []));
33319
33279
  function replaceName(n) {
33320
33280
  const c = constants5[n.str];
33321
- if (c === void 0 || names[n.str] !== 1)
33281
+ if (c === void 0 || names2[n.str] !== 1)
33322
33282
  return n;
33323
- delete names[n.str];
33283
+ delete names2[n.str];
33324
33284
  return c;
33325
33285
  }
33326
33286
  function canOptimize(e) {
33327
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants5[c.str] !== void 0);
33287
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants5[c.str] !== void 0);
33328
33288
  }
33329
33289
  }
33330
- function subtractNames(names, from) {
33290
+ function subtractNames(names2, from) {
33331
33291
  for (const n in from)
33332
- names[n] = (names[n] || 0) - (from[n] || 0);
33292
+ names2[n] = (names2[n] || 0) - (from[n] || 0);
33333
33293
  }
33334
33294
  function not(x) {
33335
33295
  return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
@@ -33527,7 +33487,7 @@ var require_names = __commonJS({
33527
33487
  "use strict";
33528
33488
  Object.defineProperty(exports, "__esModule", { value: true });
33529
33489
  var codegen_1 = require_codegen();
33530
- var names = {
33490
+ var names2 = {
33531
33491
  // validation function arguments
33532
33492
  data: new codegen_1.Name("data"),
33533
33493
  // data passed to validation function
@@ -33556,7 +33516,7 @@ var require_names = __commonJS({
33556
33516
  jsonLen: new codegen_1.Name("jsonLen"),
33557
33517
  jsonPart: new codegen_1.Name("jsonPart")
33558
33518
  };
33559
- exports.default = names;
33519
+ exports.default = names2;
33560
33520
  }
33561
33521
  });
33562
33522
 
@@ -42928,8 +42888,8 @@ var require_standalone = __commonJS({
42928
42888
  }
42929
42889
  function setUsedState(name, state) {
42930
42890
  const { prefix } = name;
42931
- const names = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
42932
- names.set(name, state);
42891
+ const names2 = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
42892
+ names2.set(name, state);
42933
42893
  }
42934
42894
  }
42935
42895
  }
@@ -58762,8 +58722,8 @@ function emoji() {
58762
58722
  }
58763
58723
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
58764
58724
  var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
58765
- var mac = (delimiter) => {
58766
- const escapedDelim = escapeRegex(delimiter ?? ":");
58725
+ var mac = (delimiter2) => {
58726
+ const escapedDelim = escapeRegex(delimiter2 ?? ":");
58767
58727
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
58768
58728
  };
58769
58729
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -73407,12 +73367,12 @@ function rewriteKeyNames(ctx) {
73407
73367
  const rewrites = /* @__PURE__ */ new Map();
73408
73368
  for (const record5 of pendingRecords.get(ctx) ?? []) {
73409
73369
  const seen = ctx.seen.get(record5);
73410
- const names = (seen?.def ?? seen?.schema)?.propertyNames;
73411
- if (!names || names === true || rewrites.has(names))
73370
+ const names2 = (seen?.def ?? seen?.schema)?.propertyNames;
73371
+ if (!names2 || names2 === true || rewrites.has(names2))
73412
73372
  continue;
73413
- const rewritten = stringifyKeyNames(bySchema, names, /* @__PURE__ */ new Set());
73414
- if (rewritten !== names)
73415
- rewrites.set(names, rewritten);
73373
+ const rewritten = stringifyKeyNames(bySchema, names2, /* @__PURE__ */ new Set());
73374
+ if (rewritten !== names2)
73375
+ rewrites.set(names2, rewritten);
73416
73376
  }
73417
73377
  if (!rewrites.size)
73418
73378
  return;
@@ -77372,9 +77332,9 @@ function judgeSelectStrategy(constants5 = judgeSelectConstants) {
77372
77332
  return kept ? done(kept, state, "judge-select: kept, no verdict") : { kind: "done", decision: base, state };
77373
77333
  }
77374
77334
  const advantage = result.answers.advantage;
77375
- const verdict = advantage > constants5.cutoff ? "capable" : "efficient";
77335
+ const verdict2 = advantage > constants5.cutoff ? "capable" : "efficient";
77376
77336
  const against = input2.judgeTrial === true && input2.mode === "auto" && input2.task.risk === "low" && base.source !== "trial";
77377
- const tier = against ? verdict === "capable" ? "efficient" : "capable" : verdict;
77337
+ const tier = against ? verdict2 === "capable" ? "efficient" : "capable" : verdict2;
77378
77338
  const { judgeTrial: _, ...fresh } = state;
77379
77339
  const next = {
77380
77340
  ...fresh,
@@ -81563,16 +81523,16 @@ async function matchModels(available, server, provider) {
81563
81523
  function parseHarnessComplete(raw) {
81564
81524
  const body = record2(raw) ?? reject("body must be a JSON object");
81565
81525
  if (!reasons.has(body.reason)) reject("invalid reason");
81566
- const usage2 = body.usage === void 0 ? void 0 : record2(body.usage) ?? reject("invalid usage");
81526
+ const usage = body.usage === void 0 ? void 0 : record2(body.usage) ?? reject("invalid usage");
81567
81527
  return {
81568
81528
  session: id(body.session, "session"),
81569
81529
  turnId: id(body.turnId, "turnId"),
81570
81530
  reason: body.reason,
81571
81531
  ...body.model === void 0 ? {} : { model: id(body.model, "model") },
81572
- ...usage2 ? {
81532
+ ...usage ? {
81573
81533
  usage: {
81574
- inputTokens: count(usage2.inputTokens, "usage.inputTokens"),
81575
- outputTokens: count(usage2.outputTokens, "usage.outputTokens")
81534
+ inputTokens: count(usage.inputTokens, "usage.inputTokens"),
81535
+ outputTokens: count(usage.outputTokens, "usage.outputTokens")
81576
81536
  }
81577
81537
  } : {}
81578
81538
  };
@@ -82017,12 +81977,12 @@ function terminalWatcher(onEnd) {
82017
81977
  continue;
82018
81978
  ended = true;
82019
81979
  const response = record4(event.response);
82020
- const usage2 = record4(response?.usage);
81980
+ const usage = record4(response?.usage);
82021
81981
  const output2 = Array.isArray(response?.output) ? response.output : [];
82022
81982
  const askedForTools = output2.some((item) => /call$/.test(String(record4(item)?.type)));
82023
81983
  onEnd(
82024
81984
  event.type === "response.completed" ? "answer" : "error",
82025
- usage2 && typeof usage2.input_tokens === "number" && typeof usage2.output_tokens === "number" ? { inputTokens: usage2.input_tokens, outputTokens: usage2.output_tokens } : void 0,
81985
+ usage && typeof usage.input_tokens === "number" && typeof usage.output_tokens === "number" ? { inputTokens: usage.input_tokens, outputTokens: usage.output_tokens } : void 0,
82026
81986
  askedForTools
82027
81987
  );
82028
81988
  }
@@ -82166,12 +82126,12 @@ function createCodexRelay(options, server) {
82166
82126
  });
82167
82127
  raw.writeHead(upstream.status, responseHeaders);
82168
82128
  let settling;
82169
- const watch = position && upstream.ok ? terminalWatcher((reason, usage2, askedForTools) => {
82129
+ const watch = position && upstream.ok ? terminalWatcher((reason, usage, askedForTools) => {
82170
82130
  const key = `${position.session}:${position.turnId}`;
82171
82131
  const sum = turns.get(key) ?? { inputTokens: 0, outputTokens: 0 };
82172
- if (usage2) {
82173
- sum.inputTokens += usage2.inputTokens;
82174
- sum.outputTokens += usage2.outputTokens;
82132
+ if (usage) {
82133
+ sum.inputTokens += usage.inputTokens;
82134
+ sum.outputTokens += usage.outputTokens;
82175
82135
  }
82176
82136
  turns.set(key, sum);
82177
82137
  if (askedForTools && reason === "answer") return;
@@ -82876,6 +82836,7 @@ import {
82876
82836
  } from "node:fs";
82877
82837
  import { join as join6 } from "node:path";
82878
82838
  var entryFile = "bizzy-routing.js";
82839
+ var npx = "npx @bizzywork/routing";
82879
82840
  function dataDirOf(io) {
82880
82841
  return io.env.BIZZY_API_DATA_DIR ?? join6(io.home, ".bizzy/routing");
82881
82842
  }
@@ -83021,7 +82982,7 @@ function claude(target, args) {
83021
82982
  return false;
83022
82983
  }
83023
82984
  }
83024
- function installClaude(target, runtime) {
82985
+ function wireClaude(target, runtime) {
83025
82986
  const marketplace = claudeDir(target);
83026
82987
  const plugin = join8(marketplace, "bizzy");
83027
82988
  rmSync3(marketplace, { recursive: true, force: true });
@@ -83044,18 +83005,16 @@ function installClaude(target, runtime) {
83044
83005
  });
83045
83006
  const added = claude(target, ["marketplace", "add", marketplace]) || claude(target, ["marketplace", "update", marketplaceName]);
83046
83007
  const installed = added && (claude(target, ["install", pluginId]) || claude(target, ["update", pluginId]));
83047
- return installed ? `${marketplace}
83048
-
83049
- Installed in Claude Code. In a running session: /reload-plugins
83050
- ` : `${marketplace}
83051
-
83052
- In Claude Code:
83008
+ return {
83009
+ done: `Wired Claude Code: ${marketplace}`,
83010
+ notes: [],
83011
+ next: installed ? "In a running Claude Code session: /reload-plugins" : `In Claude Code:
83053
83012
  /plugin marketplace add ${marketplace}
83054
83013
  /plugin install ${pluginId}
83055
- /reload-plugins
83056
- `;
83014
+ /reload-plugins`
83015
+ };
83057
83016
  }
83058
- function installOmp(target, runtime) {
83017
+ function wireOmp(target, runtime) {
83059
83018
  const extension = ompDir(target);
83060
83019
  rmSync3(extension, { recursive: true, force: true });
83061
83020
  cpSync2(join8(runtime, "harnesses/omp"), extension, { recursive: true });
@@ -83063,13 +83022,13 @@ function installOmp(target, runtime) {
83063
83022
  url: `http://127.0.0.1:${target.port}`,
83064
83023
  server: serverCommand(target.io, runtime, target.dataDir, target.port)
83065
83024
  });
83066
- return `${extension}
83067
-
83068
- In omp:
83069
- /model bizzy/auto routes among the models you are logged in to; @default serves when routing is off
83070
- `;
83025
+ return {
83026
+ done: `Wired omp: ${extension}`,
83027
+ notes: [],
83028
+ next: "In omp: /model bizzy/auto\nIt routes among the models you are logged in to; @default serves when routing is off."
83029
+ };
83071
83030
  }
83072
- function installCodex(target, runtime) {
83031
+ function wireCodex(target, runtime) {
83073
83032
  const profile = codexProfile(target);
83074
83033
  const text = `${codexHeader} Run: codex -p bizzy
83075
83034
  model = "bizzy-auto"
@@ -83082,26 +83041,20 @@ wire_api = "responses"
83082
83041
  requires_openai_auth = true
83083
83042
  `;
83084
83043
  mkdirSync4(resolve2(profile, ".."), { recursive: true });
83085
- let note = "";
83044
+ const notes = [];
83086
83045
  if (existsSync3(profile) && readFileSync5(profile, "utf8") !== text) {
83087
83046
  const backup = `${profile}.${Date.now()}.bak`;
83088
83047
  copyFileSync(profile, backup);
83089
- note = `backed up the old profile to ${backup}
83090
- `;
83048
+ notes.push(`Backed up the old profile to ${backup}`);
83091
83049
  }
83092
83050
  writeFileSync3(profile, text);
83093
- const service = installService(target.io, runtime, target.dataDir, target.port);
83094
- return `${note}${profile}
83095
- ${service}
83096
- Then:
83097
- codex -p bizzy
83098
- `;
83051
+ notes.push(installService(target.io, runtime, target.dataDir, target.port).trim());
83052
+ return { done: `Wired Codex: ${profile}`, notes, next: "codex -p bizzy" };
83099
83053
  }
83100
- function install(harness, target) {
83101
- const runtime = installRuntime(target.io, target.dataDir);
83102
- if (harness === "claude-code") return installClaude(target, runtime);
83103
- if (harness === "omp") return installOmp(target, runtime);
83104
- return installCodex(target, runtime);
83054
+ function wire(harness, target, runtime) {
83055
+ if (harness === "claude-code") return wireClaude(target, runtime);
83056
+ if (harness === "omp") return wireOmp(target, runtime);
83057
+ return wireCodex(target, runtime);
83105
83058
  }
83106
83059
  function uninstall(harness, target, purge) {
83107
83060
  const lines2 = [];
@@ -83150,7 +83103,7 @@ async function diagnose(target) {
83150
83103
  const { io, dataDir } = target;
83151
83104
  const checks = [];
83152
83105
  const add = (check2) => checks.push(check2);
83153
- const reinstall = "run `bizzy-routing install <harness>` again";
83106
+ const reinstall = `run \`${npx} install\` again`;
83154
83107
  const runtime = join9(dataDir, "runtime", entryFile);
83155
83108
  add(
83156
83109
  existsSync4(runtime) ? { name: "runtime", status: "ok", detail: runtime } : { name: "runtime", status: "fail", detail: "no runtime copy", fix: reinstall }
@@ -83198,14 +83151,14 @@ async function diagnose(target) {
83198
83151
  name: "routing key",
83199
83152
  status: "warn",
83200
83153
  detail: "none: turns route with Bizzy's own rules",
83201
- fix: "run `bizzy-routing key`"
83154
+ fix: `run \`${npx} key\``
83202
83155
  });
83203
83156
  else if (!routingKeyShape.test(key))
83204
83157
  add({
83205
83158
  name: "routing key",
83206
83159
  status: "fail",
83207
83160
  detail: "malformed",
83208
- fix: "run `bizzy-routing key` with the key you were given"
83161
+ fix: `run \`${npx} key\` with the key you were given`
83209
83162
  });
83210
83163
  else {
83211
83164
  const status2 = await answers(`${hosted.replace(/\/+$/, "")}/v1/settle`, {
@@ -83218,7 +83171,7 @@ async function diagnose(target) {
83218
83171
  name: "routing key",
83219
83172
  status: "fail",
83220
83173
  detail: `refused by ${hosted}`,
83221
- fix: "run `bizzy-routing key` with a current key"
83174
+ fix: `run \`${npx} key\` with a current key`
83222
83175
  } : {
83223
83176
  name: "hosted API",
83224
83177
  status: "fail",
@@ -83241,7 +83194,7 @@ async function diagnose(target) {
83241
83194
  name: harness,
83242
83195
  status: "fail",
83243
83196
  detail: "wired to another runtime, Node or port",
83244
- fix: `run \`bizzy-routing install ${harness}\` again`
83197
+ fix: `run \`${npx} install ${harness}\` again`
83245
83198
  }
83246
83199
  );
83247
83200
  }
@@ -83251,7 +83204,7 @@ async function diagnose(target) {
83251
83204
  name: "codex service",
83252
83205
  status: "fail",
83253
83206
  detail: "no login service",
83254
- fix: "run `bizzy-routing install codex` again"
83207
+ fix: `run \`${npx} install codex\` again`
83255
83208
  });
83256
83209
  const up = await answers(`http://127.0.0.1:${target.port}/v1/harness/step`) === 405;
83257
83210
  add(
@@ -83259,7 +83212,7 @@ async function diagnose(target) {
83259
83212
  name: "server",
83260
83213
  status: installed.includes("codex") ? "fail" : "warn",
83261
83214
  detail: `not running on 127.0.0.1:${target.port}${installed.includes("codex") ? "" : "; the mod and extension start it when needed"}`,
83262
- ...installed.includes("codex") ? { fix: "run `bizzy-routing serve`, or install codex again for its service" } : {}
83215
+ ...installed.includes("codex") ? { fix: `run \`${npx} serve\`, or \`${npx} install codex\` again for its service` } : {}
83263
83216
  }
83264
83217
  );
83265
83218
  if (!installed.length)
@@ -83267,17 +83220,10 @@ async function diagnose(target) {
83267
83220
  name: "harnesses",
83268
83221
  status: "warn",
83269
83222
  detail: "none installed",
83270
- fix: "run `bizzy-routing install <harness>`"
83223
+ fix: `run \`${npx} install\``
83271
83224
  });
83272
83225
  return checks;
83273
83226
  }
83274
- function formatChecks(checks) {
83275
- const mark = { ok: "ok ", warn: "warn", fail: "FAIL" };
83276
- return `${checks.map(
83277
- (check2) => `${mark[check2.status]} ${check2.name}: ${check2.detail}${check2.fix ? ` (${check2.fix})` : ""}`
83278
- ).join("\n")}
83279
- `;
83280
- }
83281
83227
  async function status(target) {
83282
83228
  const checks = await diagnose(target);
83283
83229
  const show = /* @__PURE__ */ new Set([
@@ -83291,14 +83237,44 @@ async function status(target) {
83291
83237
  "server",
83292
83238
  "harnesses"
83293
83239
  ]);
83294
- const lines2 = checks.filter((check2) => show.has(check2.name)).map((check2) => `${check2.name}: ${check2.detail}`);
83295
- return `bizzy-routing ${target.io.version}
83296
- ${lines2.join("\n")}
83297
- `;
83240
+ return checks.filter((check2) => show.has(check2.name)).map(({ name, status: status2, detail }) => ({ name, status: status2, detail }));
83241
+ }
83242
+
83243
+ // bizzy-routing/launcher/src/menu.ts
83244
+ import { existsSync as existsSync5 } from "node:fs";
83245
+ import { delimiter, join as join10 } from "node:path";
83246
+ var names = {
83247
+ "claude-code": "Claude Code",
83248
+ omp: "oh-my-pi (omp)",
83249
+ codex: "Codex"
83250
+ };
83251
+ var commands = {
83252
+ "claude-code": "claude",
83253
+ omp: "omp",
83254
+ codex: "codex"
83255
+ };
83256
+ function onPath(io, command) {
83257
+ return (io.env.PATH ?? "").split(delimiter).some((dir) => dir && existsSync5(join10(dir, command)));
83258
+ }
83259
+ function noteFor(harness, target) {
83260
+ if (existsSync5(wiringFile(harness, target))) return "installed, picking it updates it";
83261
+ return onPath(target.io, commands[harness]) ? `${commands[harness]} found` : "not found";
83262
+ }
83263
+ async function pickHarness(target, { offerHelp }) {
83264
+ const choices = Object.keys(names).map(
83265
+ (harness) => ({
83266
+ value: harness,
83267
+ label: names[harness],
83268
+ hint: noteFor(harness, target)
83269
+ })
83270
+ );
83271
+ if (offerHelp) choices.push({ value: "help", label: "Show all commands" });
83272
+ const picked = await target.io.ui.select("Which harness should Bizzy route in?", choices);
83273
+ return picked === "help" ? void 0 : picked;
83298
83274
  }
83299
83275
 
83300
83276
  // bizzy-routing/launcher/src/serve.ts
83301
- import { join as join10 } from "node:path";
83277
+ import { join as join11 } from "node:path";
83302
83278
  async function serve(io) {
83303
83279
  const dataDir = dataDirOf(io);
83304
83280
  const env = {
@@ -83309,7 +83285,7 @@ async function serve(io) {
83309
83285
  const log = (line) => io.stderr(`${line}
83310
83286
  `);
83311
83287
  try {
83312
- return await startLocalServer(env, log, { docsDir: join10(io.bundleDir, "static") });
83288
+ return await startLocalServer(env, log, { docsDir: join11(io.bundleDir, "static") });
83313
83289
  } catch (error62) {
83314
83290
  const port = env.PORT ?? "4100";
83315
83291
  if (error62.code !== "EADDRINUSE" || !await bizzyAnswers(port))
@@ -83331,38 +83307,84 @@ async function bizzyAnswers(port) {
83331
83307
 
83332
83308
  // bizzy-routing/launcher/src/main.ts
83333
83309
  var harnesses2 = ["claude-code", "omp", "codex"];
83334
- var usage = `Usage: bizzy-routing <command>
83335
-
83336
- install <claude-code|omp|codex> [--dir <dir>] [--port <port>] [--key-stdin] [--no-share-prompts]
83337
- Copy the routing server to ~/.bizzy/routing/runtime and wire the harness to it. On a terminal it asks
83338
- once for your routing key; --no-share-prompts keeps prompts on this machine (--share-prompts undoes it).
83339
- uninstall <claude-code|omp|codex> [--dir <dir>] [--purge]
83340
- Remove what install wrote; --purge also removes ~/.bizzy/routing (data and keys).
83341
- serve
83342
- Run the routing server on 127.0.0.1 (PORT, default 4100).
83343
- key [--stdin]
83344
- Save the routing key to ~/.bizzy/routing/.env, asking for it unless --stdin.
83345
- status
83346
- What's installed and how it routes.
83347
- doctor [--port <port>]
83348
- Check Node, the runtime, the key, the hosted API, the server and each harness.
83310
+ var help = `Bizzy Auto picks the model for each request in Claude Code, oh-my-pi (omp) or Codex.
83311
+
83312
+ Usage: ${npx} [command] [options]
83313
+
83314
+ Run it with no command to pick a harness and set it up.
83315
+
83316
+ Commands:
83317
+ install [harness] Set up routing in a harness: claude-code, omp or codex. Copies the server to
83318
+ ~/.bizzy/routing/runtime, wires the harness to it, and asks once for your routing
83319
+ key. With no harness, asks which one.
83320
+ uninstall <harness> Remove what install wrote for that harness.
83321
+ key Save or replace your routing key in ~/.bizzy/routing/.env.
83322
+ status Show what's installed and how it routes.
83323
+ doctor Check the runtime, key, hosted API, server and each harness, and say how to fix them.
83324
+ serve Run the routing server on 127.0.0.1 (PORT, default 4100).
83325
+ help Show this help.
83326
+
83327
+ Options:
83328
+ --dir <dir> install, uninstall: use this folder instead of the harness's own.
83329
+ --port <port> install, uninstall, doctor: the server's port (default 4100).
83330
+ --key-stdin install: read the routing key from stdin instead of asking.
83331
+ --no-share-prompts install: keep prompts on this machine; the hosted API then routes on its rules.
83332
+ --share-prompts install: send prompts to the hosted judge again (the default).
83333
+ --stdin key: read the key from stdin instead of asking.
83334
+ --purge uninstall: also remove ~/.bizzy/routing, with its data and key.
83335
+ -h, --help Show this help.
83336
+ -v, --version Show the version.
83337
+
83338
+ Examples:
83339
+ ${npx} pick a harness and set it up
83340
+ ${npx} install claude-code set up Claude Code directly
83341
+ ${npx} doctor check the setup
83349
83342
  `;
83350
83343
  function saveKey(target, raw) {
83351
83344
  const key = raw.trim();
83352
83345
  if (!routingKeyShape.test(key))
83353
83346
  throw new Error("that isn't a routing key: 32 or more letters, digits, '-' or '_'");
83354
83347
  writeEnvValues(target.dataDir, { BIZZY_ROUTING_KEY: key });
83355
- return `saved the routing key to ${envPath(target.dataDir)}; a running server reads it when it next starts
83356
- `;
83357
- }
83358
- async function askKey(io) {
83359
- return io.interactive ? io.askSecret("Bizzy routing key: ") : io.readStdin();
83348
+ return `Saved the routing key to ${envPath(target.dataDir)}; a running server reads it when it next starts`;
83360
83349
  }
83350
+ var keyHint = "Paste it, or press Enter to skip: turns then route with Bizzy's own rules on this machine.";
83361
83351
  function harnessOf(name) {
83362
83352
  if (harnesses2.includes(name)) return name;
83363
- throw new Error(`expected one of ${harnesses2.join(", ")}
83364
-
83365
- ${usage}`);
83353
+ throw new Error(`expected one of ${harnesses2.join(", ")}; run \`${npx} help\` for usage`);
83354
+ }
83355
+ async function installFlow(harness, target, flags) {
83356
+ const { io } = target;
83357
+ const { ui } = io;
83358
+ const runtime = await ui.step(
83359
+ "Copying the routing server",
83360
+ () => installRuntime(io, target.dataDir),
83361
+ (dir) => `Copied the routing server to ${dir}`
83362
+ );
83363
+ const wired = await ui.step(
83364
+ `Wiring ${names[harness]}`,
83365
+ () => wire(harness, target, runtime),
83366
+ (result) => result.done
83367
+ );
83368
+ for (const note of wired.notes) ui.message(note);
83369
+ const hasKey = io.env.BIZZY_ROUTING_KEY ?? readEnvFile(target.dataDir).BIZZY_ROUTING_KEY;
83370
+ const key = flags.keyStdin ? await io.readStdin() : io.interactive && !hasKey ? await ui.password("Bizzy routing key", keyHint) : "";
83371
+ if (key.trim())
83372
+ await ui.step(
83373
+ "Saving the routing key",
83374
+ () => saveKey(target, key),
83375
+ (done) => done
83376
+ );
83377
+ else if (io.interactive && !hasKey) ui.warn("No routing key: turns route with Bizzy's own rules");
83378
+ if (flags.sharePrompts === false) writeEnvValues(target.dataDir, { BIZZY_SHARE_PROMPTS: "0" });
83379
+ else if (flags.sharePrompts) writeEnvValues(target.dataDir, { BIZZY_SHARE_PROMPTS: void 0 });
83380
+ ui.note(wired.next, "Next");
83381
+ }
83382
+ function verdict(checks) {
83383
+ const count2 = (status2) => checks.filter((check2) => check2.status === status2).length;
83384
+ const plural2 = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
83385
+ if (count2("fail")) return `${plural2(count2("fail"), "problem")} to fix`;
83386
+ if (count2("warn")) return `Working, with ${plural2(count2("warn"), "warning")}`;
83387
+ return "All good";
83366
83388
  }
83367
83389
  async function run2(io) {
83368
83390
  const { values, positionals } = parseArgs({
@@ -83386,9 +83408,13 @@ async function run2(io) {
83386
83408
  `);
83387
83409
  return { exit: 0 };
83388
83410
  }
83389
- if (values.help || !command) {
83390
- io.stdout(usage);
83391
- return { exit: values.help ? 0 : 1 };
83411
+ if (values.help || command === "help") {
83412
+ io.stdout(help);
83413
+ return { exit: 0 };
83414
+ }
83415
+ if (!command && !io.interactive) {
83416
+ io.stdout(help);
83417
+ return { exit: 1 };
83392
83418
  }
83393
83419
  if (command === "serve") {
83394
83420
  const app = await serve(io);
@@ -83402,29 +83428,66 @@ async function run2(io) {
83402
83428
  port,
83403
83429
  ...values.dir ? { dir: values.dir } : {}
83404
83430
  };
83405
- if (command === "install") {
83406
- io.stdout(install(harnessOf(name), target));
83407
- const hasKey = io.env.BIZZY_ROUTING_KEY ?? readEnvFile(target.dataDir).BIZZY_ROUTING_KEY;
83408
- if (values["key-stdin"]) io.stdout(saveKey(target, await io.readStdin()));
83409
- else if (io.interactive && !hasKey) {
83410
- const key = await io.askSecret("Bizzy routing key (Enter to route on this machine only): ");
83411
- if (key.trim()) io.stdout(saveKey(target, key));
83412
- }
83413
- if (values["no-share-prompts"]) writeEnvValues(target.dataDir, { BIZZY_SHARE_PROMPTS: "0" });
83414
- else if (values["share-prompts"])
83415
- writeEnvValues(target.dataDir, { BIZZY_SHARE_PROMPTS: void 0 });
83416
- } else if (command === "uninstall")
83417
- io.stdout(uninstall(harnessOf(name), target, values.purge === true));
83418
- else if (command === "key")
83419
- io.stdout(saveKey(target, values.stdin ? await io.readStdin() : await askKey(io)));
83420
- else if (command === "status") io.stdout(await status(target));
83421
- else if (command === "doctor") {
83422
- const checks = await diagnose(target);
83423
- io.stdout(formatChecks(checks));
83431
+ const flags = {
83432
+ keyStdin: values["key-stdin"] === true,
83433
+ sharePrompts: values["no-share-prompts"] ? false : values["share-prompts"] ? true : void 0
83434
+ };
83435
+ if (command && !["install", "uninstall", "key", "status", "doctor"].includes(command))
83436
+ throw new Error(`unknown command: ${command}; run \`${npx} help\` for usage`);
83437
+ const { ui } = io;
83438
+ ui.intro(`Bizzy routing ${io.version}`);
83439
+ if (!command) {
83440
+ ui.message("Picks the model for each request in Claude Code, oh-my-pi (omp) or Codex.");
83441
+ const picked = await pickHarness(target, { offerHelp: true });
83442
+ if (!picked) {
83443
+ ui.outro("Every command:");
83444
+ io.stdout(`
83445
+ ${help}`);
83446
+ return { exit: 0 };
83447
+ }
83448
+ await installFlow(picked, target, flags);
83449
+ ui.outro(`Done. Check it any time with: ${npx} doctor`);
83450
+ } else if (command === "install") {
83451
+ const harness = name || !io.interactive ? harnessOf(name) : await pickHarness(target, { offerHelp: false });
83452
+ await installFlow(harness, target, flags);
83453
+ ui.outro("Done");
83454
+ } else if (command === "uninstall") {
83455
+ const harness = harnessOf(name);
83456
+ let purge = values.purge === true;
83457
+ if (purge && io.interactive)
83458
+ purge = await ui.confirm(`Also delete ${target.dataDir}, with your routing key and data?`);
83459
+ await ui.step(
83460
+ `Removing ${names[harness]}`,
83461
+ () => uninstall(harness, target, purge),
83462
+ (done) => done.trim()
83463
+ );
83464
+ ui.outro("Done");
83465
+ } else if (command === "key") {
83466
+ const key = values.stdin ? await io.readStdin() : io.interactive ? await ui.password("Bizzy routing key", "Paste the key you were given.") : await io.readStdin();
83467
+ await ui.step(
83468
+ "Saving the routing key",
83469
+ () => saveKey(target, key),
83470
+ (done) => done
83471
+ );
83472
+ ui.outro("Done");
83473
+ } else if (command === "status") {
83474
+ const checks = await ui.step(
83475
+ "Reading the setup",
83476
+ () => status(target),
83477
+ () => "Setup:"
83478
+ );
83479
+ ui.message(ui.checks(checks));
83480
+ ui.outro(verdict(checks));
83481
+ } else if (command === "doctor") {
83482
+ const checks = await ui.step(
83483
+ "Checking the setup",
83484
+ () => diagnose(target),
83485
+ (done) => `Ran ${done.length} checks`
83486
+ );
83487
+ ui.message(ui.checks(checks));
83488
+ ui.outro(verdict(checks));
83424
83489
  return { exit: checks.some((check2) => check2.status === "fail") ? 1 : 0 };
83425
- } else throw new Error(`unknown command: ${command}
83426
-
83427
- ${usage}`);
83490
+ }
83428
83491
  return { exit: 0 };
83429
83492
  }
83430
83493
  export {