@otto-code/brain 0.7.5

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.
Files changed (150) hide show
  1. package/bin/otto-brain +2 -0
  2. package/dist/bench/context-corpus.d.ts +58 -0
  3. package/dist/bench/context-corpus.js +210 -0
  4. package/dist/bench/corpus.d.ts +31 -0
  5. package/dist/bench/corpus.js +379 -0
  6. package/dist/bench/curated-repos.d.ts +35 -0
  7. package/dist/bench/curated-repos.js +41 -0
  8. package/dist/bench/health.d.ts +50 -0
  9. package/dist/bench/health.js +112 -0
  10. package/dist/bench/index.d.ts +103 -0
  11. package/dist/bench/index.js +209 -0
  12. package/dist/bench/mine.d.ts +32 -0
  13. package/dist/bench/mine.js +101 -0
  14. package/dist/bench/repo-task.d.ts +93 -0
  15. package/dist/bench/repo-task.js +380 -0
  16. package/dist/bench/repo.d.ts +125 -0
  17. package/dist/bench/repo.js +195 -0
  18. package/dist/bench/rescore.d.ts +41 -0
  19. package/dist/bench/rescore.js +127 -0
  20. package/dist/bench/tasks.d.ts +124 -0
  21. package/dist/bench/tasks.js +1249 -0
  22. package/dist/bench/verify.d.ts +142 -0
  23. package/dist/bench/verify.js +350 -0
  24. package/dist/cli.d.ts +13 -0
  25. package/dist/cli.js +72 -0
  26. package/dist/commands/bench.d.ts +20 -0
  27. package/dist/commands/bench.js +222 -0
  28. package/dist/commands/calibrate.d.ts +19 -0
  29. package/dist/commands/calibrate.js +75 -0
  30. package/dist/commands/catalog.d.ts +32 -0
  31. package/dist/commands/catalog.js +48 -0
  32. package/dist/commands/config.d.ts +13 -0
  33. package/dist/commands/config.js +90 -0
  34. package/dist/commands/lifecycle.d.ts +29 -0
  35. package/dist/commands/lifecycle.js +194 -0
  36. package/dist/commands/pull.d.ts +22 -0
  37. package/dist/commands/pull.js +135 -0
  38. package/dist/commands/report.d.ts +10 -0
  39. package/dist/commands/report.js +34 -0
  40. package/dist/commands/rescore.d.ts +11 -0
  41. package/dist/commands/rescore.js +48 -0
  42. package/dist/commands/runtime.d.ts +21 -0
  43. package/dist/commands/runtime.js +62 -0
  44. package/dist/commands/scan.d.ts +24 -0
  45. package/dist/commands/scan.js +55 -0
  46. package/dist/commands/search.d.ts +31 -0
  47. package/dist/commands/search.js +135 -0
  48. package/dist/commands/share.d.ts +26 -0
  49. package/dist/commands/share.js +148 -0
  50. package/dist/commands/sweep.d.ts +21 -0
  51. package/dist/commands/sweep.js +69 -0
  52. package/dist/commands/ui.d.ts +9 -0
  53. package/dist/commands/ui.js +28 -0
  54. package/dist/config/env.d.ts +10 -0
  55. package/dist/config/env.js +48 -0
  56. package/dist/config/index.d.ts +9 -0
  57. package/dist/config/index.js +9 -0
  58. package/dist/config/otto-home.d.ts +2 -0
  59. package/dist/config/otto-home.js +24 -0
  60. package/dist/config/paths.d.ts +20 -0
  61. package/dist/config/paths.js +33 -0
  62. package/dist/config/private-files.d.ts +3 -0
  63. package/dist/config/private-files.js +32 -0
  64. package/dist/config/profiles.d.ts +34 -0
  65. package/dist/config/profiles.js +116 -0
  66. package/dist/config/schema.d.ts +1035 -0
  67. package/dist/config/schema.js +191 -0
  68. package/dist/config/store.d.ts +11 -0
  69. package/dist/config/store.js +73 -0
  70. package/dist/gguf.d.ts +61 -0
  71. package/dist/gguf.js +231 -0
  72. package/dist/gpu.d.ts +12 -0
  73. package/dist/gpu.js +49 -0
  74. package/dist/index.d.ts +14 -0
  75. package/dist/index.js +13 -0
  76. package/dist/main.d.ts +2 -0
  77. package/dist/main.js +5 -0
  78. package/dist/models/dirs.d.ts +9 -0
  79. package/dist/models/dirs.js +21 -0
  80. package/dist/models/download.d.ts +31 -0
  81. package/dist/models/download.js +105 -0
  82. package/dist/models/enrich.d.ts +36 -0
  83. package/dist/models/enrich.js +68 -0
  84. package/dist/models/hf.d.ts +62 -0
  85. package/dist/models/hf.js +114 -0
  86. package/dist/models/index.d.ts +15 -0
  87. package/dist/models/index.js +49 -0
  88. package/dist/models/manage.d.ts +27 -0
  89. package/dist/models/manage.js +112 -0
  90. package/dist/models/pick.d.ts +3 -0
  91. package/dist/models/pick.js +36 -0
  92. package/dist/models/scan.d.ts +13 -0
  93. package/dist/models/scan.js +185 -0
  94. package/dist/ops/archive.d.ts +34 -0
  95. package/dist/ops/archive.js +105 -0
  96. package/dist/ops/calibrate.d.ts +49 -0
  97. package/dist/ops/calibrate.js +74 -0
  98. package/dist/ops/report.d.ts +26 -0
  99. package/dist/ops/report.js +532 -0
  100. package/dist/ops/results.d.ts +207 -0
  101. package/dist/ops/results.js +250 -0
  102. package/dist/ops/sweep.d.ts +77 -0
  103. package/dist/ops/sweep.js +126 -0
  104. package/dist/output/index.d.ts +5 -0
  105. package/dist/output/index.js +5 -0
  106. package/dist/output/render.d.ts +4 -0
  107. package/dist/output/render.js +96 -0
  108. package/dist/output/types.d.ts +52 -0
  109. package/dist/output/types.js +9 -0
  110. package/dist/output/with-output.d.ts +3 -0
  111. package/dist/output/with-output.js +42 -0
  112. package/dist/run.d.ts +5 -0
  113. package/dist/run.js +19 -0
  114. package/dist/runtime/args.d.ts +21 -0
  115. package/dist/runtime/args.js +71 -0
  116. package/dist/runtime/index.d.ts +13 -0
  117. package/dist/runtime/index.js +41 -0
  118. package/dist/runtime/lmstudio.d.ts +10 -0
  119. package/dist/runtime/lmstudio.js +88 -0
  120. package/dist/runtime/managed.d.ts +26 -0
  121. package/dist/runtime/managed.js +148 -0
  122. package/dist/service/model-selector.d.ts +36 -0
  123. package/dist/service/model-selector.js +123 -0
  124. package/dist/service/pid-lock.d.ts +18 -0
  125. package/dist/service/pid-lock.js +50 -0
  126. package/dist/service/router.d.ts +144 -0
  127. package/dist/service/router.js +746 -0
  128. package/dist/service/scheduler.d.ts +74 -0
  129. package/dist/service/scheduler.js +110 -0
  130. package/dist/service/serve.d.ts +41 -0
  131. package/dist/service/serve.js +278 -0
  132. package/dist/service/supervisor.d.ts +67 -0
  133. package/dist/service/supervisor.js +222 -0
  134. package/dist/service/tailscale.d.ts +19 -0
  135. package/dist/service/tailscale.js +62 -0
  136. package/dist/service/tls.d.ts +77 -0
  137. package/dist/service/tls.js +192 -0
  138. package/dist/sysmon.d.ts +50 -0
  139. package/dist/sysmon.js +103 -0
  140. package/dist/tui/app.d.ts +208 -0
  141. package/dist/tui/app.js +1801 -0
  142. package/dist/tui/screen.d.ts +72 -0
  143. package/dist/tui/screen.js +176 -0
  144. package/dist/types.d.ts +76 -0
  145. package/dist/types.js +7 -0
  146. package/dist/version.d.ts +2 -0
  147. package/dist/version.js +8 -0
  148. package/dist/vram.d.ts +67 -0
  149. package/dist/vram.js +132 -0
  150. package/package.json +58 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Per-model hosting profiles and the measured-calibration lookup, ported from the
3
+ * original profiles.js. Only settings with a demonstrated effect on stability or
4
+ * throughput are stored — notably `reasoningBudget`, which defaults to -1
5
+ * (unrestricted) in llama-server and in that state makes thinking models spend an
6
+ * entire token allowance reasoning and return no content at all.
7
+ */
8
+ import type { Model } from "../types.js";
9
+ import { type Calibration, type Profile, type ProfileDefaults, type ProfilesStore } from "./schema.js";
10
+ export declare function defaultProfile(model: Model | null, defaults?: ProfileDefaults): Profile;
11
+ /** Stored profile for a model, falling back to computed defaults. */
12
+ export declare function forModel(store: ProfilesStore, model: Model, defaults?: ProfileDefaults): Profile;
13
+ export declare function put(store: ProfilesStore, model: Model, profile: Profile): ProfilesStore;
14
+ /** Calibration is keyed by cache types, since those change bytes/token. */
15
+ export declare function calibrationKey(profile: Profile): string;
16
+ /**
17
+ * True when this model has a stored calibration, but for different cache types
18
+ * than the profile currently uses - i.e. the measurement is stale and the budget
19
+ * has fallen back to the theoretical estimate. Drives the "recalibrate" prompt.
20
+ */
21
+ export declare function hasStaleCalibration(store: ProfilesStore, model: Model, profile: Profile): boolean;
22
+ /**
23
+ * KV cost per token is a property of the attention geometry, not of the particular
24
+ * file: two models sharing an architecture and head dimensions cost the same per
25
+ * layer regardless of quantisation or fine-tuning. Storing the measurement *per
26
+ * layer* and keying it without the layer count lets one calibration serve a whole
27
+ * family — which matters on a library holding a dozen variants of one base, and is
28
+ * necessary because MTP builds carry an extra multi-token-prediction layer (65
29
+ * blocks where the base has 64) and would otherwise never match.
30
+ */
31
+ export declare function geometryKey(model: Model, profile: Profile): string | null;
32
+ export declare function getCalibration(store: ProfilesStore, model: Model, profile: Profile): Calibration | null;
33
+ export declare function putCalibration(store: ProfilesStore, model: Model, profile: Profile, measurement: Calibration): ProfilesStore;
34
+ //# sourceMappingURL=profiles.d.ts.map
@@ -0,0 +1,116 @@
1
+ import { DEFAULT_REASONING_MESSAGE, } from "./schema.js";
2
+ export function defaultProfile(model, defaults) {
3
+ const nativeContext = model?.metadata?.contextLength || 32768;
4
+ const contextCap = defaults?.contextCap ?? 225000;
5
+ return {
6
+ modelId: model?.id ?? null,
7
+ modelPath: model?.modelPath ?? null,
8
+ mmprojPath: model?.mmprojPath ?? null,
9
+ // Long context is the point of this hardware; start at the native limit and
10
+ // let the VRAM budget pull it down.
11
+ contextSize: Math.min(nativeContext, contextCap),
12
+ cacheTypeK: defaults?.cacheTypeK ?? "q8_0",
13
+ cacheTypeV: defaults?.cacheTypeV ?? "q8_0",
14
+ flashAttention: defaults?.flashAttention ?? true, // required for a quantised V cache
15
+ gpuLayers: 999, // everything on GPU; the budget check guards this
16
+ vision: Boolean(model?.mmprojPath),
17
+ reasoningBudget: defaults?.reasoningBudget ?? 1536,
18
+ reasoningBudgetMessage: DEFAULT_REASONING_MESSAGE,
19
+ parallelSlots: defaults?.parallelSlots ?? 1, // one agent at a time: max context per request
20
+ batchSize: null,
21
+ ubatchSize: null,
22
+ extraArgs: [],
23
+ };
24
+ }
25
+ /** Stored profile for a model, falling back to computed defaults. */
26
+ export function forModel(store, model, defaults) {
27
+ const stored = store.profiles[model.id];
28
+ const base = defaultProfile(model, defaults);
29
+ if (!stored)
30
+ return base;
31
+ // Paths are re-derived so a moved model library does not break the profile.
32
+ return { ...base, ...stored, modelPath: model.modelPath, mmprojPath: model.mmprojPath };
33
+ }
34
+ export function put(store, model, profile) {
35
+ store.profiles[model.id] = { ...profile, modelId: model.id };
36
+ return store;
37
+ }
38
+ /** Calibration is keyed by cache types, since those change bytes/token. */
39
+ export function calibrationKey(profile) {
40
+ return `${profile.cacheTypeK}:${profile.cacheTypeV}`;
41
+ }
42
+ /**
43
+ * True when this model has a stored calibration, but for different cache types
44
+ * than the profile currently uses - i.e. the measurement is stale and the budget
45
+ * has fallen back to the theoretical estimate. Drives the "recalibrate" prompt.
46
+ */
47
+ export function hasStaleCalibration(store, model, profile) {
48
+ const measured = store.calibrations?.[model.id];
49
+ if (!measured)
50
+ return false;
51
+ const key = calibrationKey(profile);
52
+ return Object.keys(measured).some((k) => k !== key);
53
+ }
54
+ /**
55
+ * KV cost per token is a property of the attention geometry, not of the particular
56
+ * file: two models sharing an architecture and head dimensions cost the same per
57
+ * layer regardless of quantisation or fine-tuning. Storing the measurement *per
58
+ * layer* and keying it without the layer count lets one calibration serve a whole
59
+ * family — which matters on a library holding a dozen variants of one base, and is
60
+ * necessary because MTP builds carry an extra multi-token-prediction layer (65
61
+ * blocks where the base has 64) and would otherwise never match.
62
+ */
63
+ export function geometryKey(model, profile) {
64
+ const md = model?.metadata;
65
+ if (!md || !md.headCountKv || !md.keyLength)
66
+ return null;
67
+ return [
68
+ md.arch,
69
+ md.headCountKv,
70
+ md.keyLength,
71
+ md.valueLength,
72
+ profile.cacheTypeK,
73
+ profile.cacheTypeV,
74
+ ].join(":");
75
+ }
76
+ export function getCalibration(store, model, profile) {
77
+ const exact = store.calibrations?.[model.id]?.[calibrationKey(profile)];
78
+ if (exact)
79
+ return exact;
80
+ // Fall back to a relative with the same geometry, rescaled to this model's layer
81
+ // count. Flagged as inherited so the UI never implies it was measured on this file.
82
+ const key = geometryKey(model, profile);
83
+ const family = key ? store.geometryCalibrations?.[key] : null;
84
+ const layers = model?.metadata?.blockCount;
85
+ if (!family || !layers || !family.kvBytesPerTokenPerLayer)
86
+ return null;
87
+ return {
88
+ kvBytesPerToken: family.kvBytesPerTokenPerLayer * layers,
89
+ baseOverheadBytes: family.baseOverheadBytes,
90
+ measuredAt: family.measuredAt,
91
+ measuredOn: family.measuredOn,
92
+ inherited: true,
93
+ };
94
+ }
95
+ export function putCalibration(store, model, profile, measurement) {
96
+ if (!store.calibrations)
97
+ store.calibrations = {};
98
+ if (!store.calibrations[model.id])
99
+ store.calibrations[model.id] = {};
100
+ store.calibrations[model.id][calibrationKey(profile)] = measurement;
101
+ const key = geometryKey(model, profile);
102
+ const layers = model?.metadata?.blockCount;
103
+ if (key && layers) {
104
+ if (!store.geometryCalibrations)
105
+ store.geometryCalibrations = {};
106
+ store.geometryCalibrations[key] = {
107
+ kvBytesPerTokenPerLayer: measurement.kvBytesPerToken / layers,
108
+ baseOverheadBytes: measurement.baseOverheadBytes,
109
+ measuredAt: measurement.measuredAt,
110
+ measuredOn: model.displayName,
111
+ measuredLayers: layers,
112
+ };
113
+ }
114
+ return store;
115
+ }
116
+ //# sourceMappingURL=profiles.js.map