@wirecat/cli-core 0.608.0 → 0.610.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +124 -1
  2. package/dist/background/deliver.d.ts +12 -1
  3. package/dist/background/deliver.js +38 -5
  4. package/dist/background/report/render.d.ts +61 -0
  5. package/dist/background/report/render.js +208 -0
  6. package/dist/background/report/schema.d.ts +66 -0
  7. package/dist/background/report/schema.js +191 -0
  8. package/dist/background/report/templates/morning-digest.email.en.liquid +79 -0
  9. package/dist/background/report/templates/morning-digest.email.ru.liquid +79 -0
  10. package/dist/background/report/templates/morning-digest.telegram.en.liquid +77 -0
  11. package/dist/background/report/templates/morning-digest.telegram.ru.liquid +77 -0
  12. package/dist/background/report/templates/morning-digest.text.en.liquid +76 -0
  13. package/dist/background/report/templates/morning-digest.text.ru.liquid +76 -0
  14. package/dist/background/report/view.d.ts +88 -0
  15. package/dist/background/report/view.js +152 -0
  16. package/dist/background/schedules.d.ts +6 -1
  17. package/dist/background/schedules.js +24 -7
  18. package/dist/cli/embedding-choice.d.ts +4 -1
  19. package/dist/cli/embedding-choice.js +6 -3
  20. package/dist/cli/messenger/models-command.js +46 -18
  21. package/dist/cli/messenger/search-answers.js +23 -2
  22. package/dist/cli/model-catalogue-command.d.ts +33 -0
  23. package/dist/cli/model-catalogue-command.js +110 -21
  24. package/dist/cli/schedule/schedule-command.js +18 -0
  25. package/dist/cli/search-left-out.d.ts +1 -0
  26. package/dist/cli/search-left-out.js +2 -0
  27. package/dist/cli/store-settings.js +39 -3
  28. package/dist/crm/cli/csv.d.ts +18 -5
  29. package/dist/crm/cli/csv.js +30 -19
  30. package/dist/crm/cli/index.d.ts +1 -0
  31. package/dist/crm/cli/index.js +1 -0
  32. package/dist/domain/business.d.ts +3 -0
  33. package/dist/domain/business.js +2 -0
  34. package/dist/embeddings/models.d.ts +185 -5
  35. package/dist/embeddings/models.js +119 -5
  36. package/dist/entities/hit.d.ts +13 -2
  37. package/dist/entities/hit.js +10 -2
  38. package/dist/entities/index.d.ts +31 -1
  39. package/dist/entities/index.js +2 -1
  40. package/dist/entities/model.d.ts +42 -1
  41. package/dist/entities/model.js +20 -1
  42. package/dist/errors/reasons.js +4 -0
  43. package/dist/render/liquid.d.ts +14 -0
  44. package/dist/render/liquid.js +30 -0
  45. package/dist/replies/template.js +3 -22
  46. package/dist/search/account-list.d.ts +3 -2
  47. package/dist/search/account-list.js +5 -4
  48. package/dist/search/lucene/plain.js +4 -1
  49. package/dist/search/question-plan.js +2 -1
  50. package/dist/sends/permissions.js +4 -0
  51. package/dist/services/embeddings-maintenance.d.ts +1 -1
  52. package/dist/services/embeddings-maintenance.js +6 -6
  53. package/dist/services/index.d.ts +2 -0
  54. package/dist/services/index.js +2 -0
  55. package/dist/services/link-scorers/chat-senders.d.ts +2 -1
  56. package/dist/services/link-scorers/chat-senders.js +13 -4
  57. package/dist/services/link-scorers/types.d.ts +1 -1
  58. package/dist/services/meeting-model.d.ts +1 -1
  59. package/dist/services/meeting-model.js +4 -4
  60. package/dist/services/messages-meaning.js +25 -4
  61. package/dist/services/metadata.d.ts +1 -1
  62. package/dist/services/model-downloads.js +1 -1
  63. package/dist/services/notes-search.d.ts +1 -1
  64. package/dist/services/notes-search.js +2 -2
  65. package/dist/services/proposals/kinds/relationship.js +1 -0
  66. package/dist/services/proposals/registry.js +3 -1
  67. package/dist/services/proposals/types.d.ts +2 -0
  68. package/dist/services/search-all-business.d.ts +18 -0
  69. package/dist/services/search-all-business.js +38 -0
  70. package/dist/services/search-all-meetings.d.ts +1 -1
  71. package/dist/services/search-all-meetings.js +7 -2
  72. package/dist/services/search-all.d.ts +12 -6
  73. package/dist/services/search-all.js +48 -12
  74. package/dist/services/text-model-choice.d.ts +50 -0
  75. package/dist/services/text-model-choice.js +151 -0
  76. package/dist/store/exports.d.ts +3 -0
  77. package/dist/store/exports.js +3 -0
  78. package/dist/store/index.d.ts +5 -1
  79. package/dist/store/index.js +3 -0
  80. package/dist/store/sqlite/business-search.d.ts +44 -0
  81. package/dist/store/sqlite/business-search.js +141 -0
  82. package/dist/store/sqlite/finance.d.ts +12 -0
  83. package/dist/store/sqlite/finance.js +38 -2
  84. package/dist/store/sqlite/involvement-queue.d.ts +2 -7
  85. package/dist/store/sqlite/involvement-queue.js +11 -14
  86. package/dist/store/sqlite/money-lines.d.ts +12 -1
  87. package/dist/store/sqlite/money-lines.js +50 -4
  88. package/dist/store/sqlite/orders.js +5 -25
  89. package/dist/store/sqlite/owner-languages.d.ts +13 -0
  90. package/dist/store/sqlite/owner-languages.js +49 -0
  91. package/dist/store/sqlite/proposed-actions.d.ts +2 -0
  92. package/dist/store/sqlite/proposed-actions.js +4 -3
  93. package/dist/store/sqlite/records.d.ts +21 -0
  94. package/dist/store/sqlite/records.js +74 -13
  95. package/dist/store/sqlite/ref-summaries.d.ts +3 -1
  96. package/dist/store/sqlite/ref-summaries.js +4 -1
  97. package/dist/store/sqlite/reported-relations.d.ts +1 -0
  98. package/dist/store/sqlite/reported-relations.js +5 -1
  99. package/dist/store/sqlite/vectors.d.ts +2 -0
  100. package/dist/store/sqlite/vectors.js +5 -0
  101. package/dist/store/store.d.ts +2 -0
  102. package/dist/store/store.js +4 -4
  103. package/dist/store/vectors.d.ts +2 -0
  104. package/dist/store/vectors.js +1 -0
  105. package/dist/terminal/prompt.d.ts +4 -0
  106. package/dist/terminal/prompt.js +21 -2
  107. package/package.json +2 -2
  108. package/parity.json +13 -0
@@ -1,3 +1,4 @@
1
+ import * as v from "valibot";
1
2
  import type { ModelFile } from "../speech/models.js";
2
3
  /**
3
4
  * The text embedding models `conversations embed` can use, each **pinned to one commit** and checked by
@@ -8,6 +9,10 @@ import type { ModelFile } from "../speech/models.js";
8
9
  export interface TextModel {
9
10
  id: string;
10
11
  title: string;
12
+ /** How large it is next to the others, for a picker: small is fast, large reads best and is slowest. */
13
+ size?: "small" | "medium" | "large";
14
+ /** Added by the owner with `models add`, kept in the shared models file. */
15
+ custom?: boolean;
11
16
  languages: string;
12
17
  licence: string;
13
18
  /** A licence the user accepts before the model is downloaded, or nothing for an open one. */
@@ -15,8 +20,8 @@ export interface TextModel {
15
20
  dims: number;
16
21
  /** What the model was trained on; a longer text is cut. */
17
22
  maxTokens: number;
18
- /** About how many ~300-token chunks a second one session embeds on 8 threads, for the estimate. */
19
- chunksPerSecond: number;
23
+ /** About how many ~300-token chunks a second one session embeds on 8 threads, for the estimate; unknown for most custom models. */
24
+ chunksPerSecond?: number;
20
25
  /** How the model's output becomes one vector. */
21
26
  pooling: "mean" | "sentence_embedding";
22
27
  /** Prepended to a search and to a stored chunk: the model was trained with them. */
@@ -31,7 +36,178 @@ export interface TextModel {
31
36
  }
32
37
  export declare const TEXT_MODELS: TextModel[];
33
38
  export declare const DEFAULT_TEXT_MODEL = "e5-small";
34
- export declare const textModel: (id: string) => TextModel;
39
+ /** A model the owner adds: the same shape as a built-in one, so it is downloaded, checked and loaded the same way. */
40
+ export declare const CustomTextModelShape: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
41
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "is not a model id: a-z, 0-9, . _ -">]>;
42
+ readonly title: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 300, undefined>]>;
43
+ readonly languages: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 300, undefined>]>;
44
+ readonly licence: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 300, undefined>]>;
45
+ readonly terms: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>, undefined>;
46
+ readonly dims: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 8192, undefined>]>;
47
+ readonly maxTokens: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 16, undefined>, v.MaxValueAction<number, 32768, undefined>]>;
48
+ readonly chunksPerSecond: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0.01, undefined>]>, undefined>;
49
+ readonly pooling: v.PicklistSchema<["mean", "sentence_embedding"], undefined>;
50
+ readonly prefix: v.StrictObjectSchema<{
51
+ readonly query: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 200, undefined>]>;
52
+ readonly passage: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 200, undefined>]>;
53
+ }, undefined>;
54
+ readonly onnx: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "is not a file inside the model's folder">]>;
55
+ readonly externalData: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "is not a file inside the model's folder">]>, undefined>;
56
+ readonly files: v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
57
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "is not a file inside the model's folder">]>;
58
+ readonly url: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>, v.StartsWithAction<string, "https://", "has to be an https address">]>;
59
+ readonly sha256: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "has to be a sha256 in hex">]>;
60
+ readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
61
+ }, undefined>, undefined>, v.MinLengthAction<{
62
+ name: string;
63
+ url: string;
64
+ sha256: string;
65
+ bytes: number;
66
+ }[], 1, undefined>, v.MaxLengthAction<{
67
+ name: string;
68
+ url: string;
69
+ sha256: string;
70
+ bytes: number;
71
+ }[], 16, undefined>]>;
72
+ }, undefined>, v.CheckAction<{
73
+ id: string;
74
+ title: string;
75
+ languages: string;
76
+ licence: string;
77
+ terms?: string | undefined;
78
+ dims: number;
79
+ maxTokens: number;
80
+ chunksPerSecond?: number | undefined;
81
+ pooling: "mean" | "sentence_embedding";
82
+ prefix: {
83
+ query: string;
84
+ passage: string;
85
+ };
86
+ onnx: string;
87
+ externalData?: string | undefined;
88
+ files: {
89
+ name: string;
90
+ url: string;
91
+ sha256: string;
92
+ bytes: number;
93
+ }[];
94
+ }, "takes the id of a model this version ships; choose another">, v.CheckAction<{
95
+ id: string;
96
+ title: string;
97
+ languages: string;
98
+ licence: string;
99
+ terms?: string | undefined;
100
+ dims: number;
101
+ maxTokens: number;
102
+ chunksPerSecond?: number | undefined;
103
+ pooling: "mean" | "sentence_embedding";
104
+ prefix: {
105
+ query: string;
106
+ passage: string;
107
+ };
108
+ onnx: string;
109
+ externalData?: string | undefined;
110
+ files: {
111
+ name: string;
112
+ url: string;
113
+ sha256: string;
114
+ bytes: number;
115
+ }[];
116
+ }, "has to list its onnx file, its external data and tokenizer.json and tokenizer_config.json among files">]>;
117
+ export type CustomTextModel = v.InferOutput<typeof CustomTextModelShape>;
118
+ declare const TextModelsSection: v.StrictObjectSchema<{
119
+ readonly use: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "is not a model id: a-z, 0-9, . _ -">]>, undefined>;
120
+ readonly custom: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
121
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "is not a model id: a-z, 0-9, . _ -">]>;
122
+ readonly title: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 300, undefined>]>;
123
+ readonly languages: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 300, undefined>]>;
124
+ readonly licence: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 300, undefined>]>;
125
+ readonly terms: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>, undefined>;
126
+ readonly dims: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 8192, undefined>]>;
127
+ readonly maxTokens: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 16, undefined>, v.MaxValueAction<number, 32768, undefined>]>;
128
+ readonly chunksPerSecond: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0.01, undefined>]>, undefined>;
129
+ readonly pooling: v.PicklistSchema<["mean", "sentence_embedding"], undefined>;
130
+ readonly prefix: v.StrictObjectSchema<{
131
+ readonly query: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 200, undefined>]>;
132
+ readonly passage: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 200, undefined>]>;
133
+ }, undefined>;
134
+ readonly onnx: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "is not a file inside the model's folder">]>;
135
+ readonly externalData: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "is not a file inside the model's folder">]>, undefined>;
136
+ readonly files: v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
137
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "is not a file inside the model's folder">]>;
138
+ readonly url: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>, v.StartsWithAction<string, "https://", "has to be an https address">]>;
139
+ readonly sha256: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "has to be a sha256 in hex">]>;
140
+ readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
141
+ }, undefined>, undefined>, v.MinLengthAction<{
142
+ name: string;
143
+ url: string;
144
+ sha256: string;
145
+ bytes: number;
146
+ }[], 1, undefined>, v.MaxLengthAction<{
147
+ name: string;
148
+ url: string;
149
+ sha256: string;
150
+ bytes: number;
151
+ }[], 16, undefined>]>;
152
+ }, undefined>, v.CheckAction<{
153
+ id: string;
154
+ title: string;
155
+ languages: string;
156
+ licence: string;
157
+ terms?: string | undefined;
158
+ dims: number;
159
+ maxTokens: number;
160
+ chunksPerSecond?: number | undefined;
161
+ pooling: "mean" | "sentence_embedding";
162
+ prefix: {
163
+ query: string;
164
+ passage: string;
165
+ };
166
+ onnx: string;
167
+ externalData?: string | undefined;
168
+ files: {
169
+ name: string;
170
+ url: string;
171
+ sha256: string;
172
+ bytes: number;
173
+ }[];
174
+ }, "takes the id of a model this version ships; choose another">, v.CheckAction<{
175
+ id: string;
176
+ title: string;
177
+ languages: string;
178
+ licence: string;
179
+ terms?: string | undefined;
180
+ dims: number;
181
+ maxTokens: number;
182
+ chunksPerSecond?: number | undefined;
183
+ pooling: "mean" | "sentence_embedding";
184
+ prefix: {
185
+ query: string;
186
+ passage: string;
187
+ };
188
+ onnx: string;
189
+ externalData?: string | undefined;
190
+ files: {
191
+ name: string;
192
+ url: string;
193
+ sha256: string;
194
+ bytes: number;
195
+ }[];
196
+ }, "has to list its onnx file, its external data and tokenizer.json and tokenizer_config.json among files">]>, undefined>, undefined>;
197
+ }, undefined>;
198
+ export type TextModelsSection = v.InferOutput<typeof TextModelsSection>;
199
+ /** The shared settings file every WireCat CLI reads, so one choice serves tg, MAX, memo and the rest. */
200
+ export declare const textModelsFile: (env?: NodeJS.ProcessEnv) => string;
201
+ export declare const readTextModelsSection: (env?: NodeJS.ProcessEnv) => TextModelsSection;
202
+ export declare const writeTextModelsSection: (section: TextModelsSection, env?: NodeJS.ProcessEnv) => void;
203
+ /** The models this version ships, then the owner's own. */
204
+ export declare const textModels: (env?: NodeJS.ProcessEnv) => TextModel[];
205
+ export declare const textModel: (id: string, env?: NodeJS.ProcessEnv) => TextModel;
206
+ /** The model every embed and every search by meaning uses when none is named: the owner's `models use`, or e5-small. */
207
+ export declare const chosenTextModel: (env?: NodeJS.ProcessEnv) => {
208
+ id: string;
209
+ from: "chosen" | "default";
210
+ };
35
211
  /**
36
212
  * Cross-encoders that read a question and one hit together and score how well the hit answers it: discovery's
37
213
  * last step. Pinned and checked as the text models are, and kept beside them. Picked in the evidence-pipeline
@@ -50,7 +226,11 @@ export interface RerankModel {
50
226
  export declare const RERANK_MODELS: RerankModel[];
51
227
  export declare const DEFAULT_RERANK_MODEL = "mmarco";
52
228
  export declare const rerankModel: (id: string) => RerankModel;
53
- /** The cosine a meaning hit must beat, measured in bench/search-quality; an unmeasured model keeps every hit. */
54
- /** A vector's model: the provider, the model and its size — vectors of two of them never mix. */
229
+ /**
230
+ * A vector's model: the provider, the model and its size — vectors of two of them never mix. A custom model's key also
231
+ * carries its weights' hash, so an id the owner redefines as another model starts from no vectors.
232
+ */
55
233
  export declare const vectorModelKey: (model: TextModel) => string;
234
+ /** The cosine a meaning hit must beat, measured in bench/search-quality; an unmeasured model keeps every hit. */
56
235
  export declare const meaningFloor: (key: string) => number;
236
+ export {};
@@ -1,11 +1,16 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
+ import * as v from "valibot";
3
+ import { storePath } from "../store/path.js";
4
+ import { readSharedSection, sharedConfigPath, writeSharedSection } from "../store/shared-config.js";
2
5
  const huggingFace = (repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`;
3
6
  const e5 = huggingFace("Xenova/multilingual-e5-small", "761b726dd34fb83930e26aab4e9ac3899aa1fa78");
7
+ const e5Large = huggingFace("Xenova/multilingual-e5-large", "00fc3aeb3dbb95842de2ac1961d33c6319acf57b");
4
8
  const gemma = huggingFace("onnx-community/embeddinggemma-300m-ONNX", "5090578d9565bb06545b4552f76e6bc2c93e4a66");
5
9
  export const TEXT_MODELS = [
6
10
  {
7
11
  id: "e5-small",
8
12
  title: "multilingual-e5-small, 8-bit",
13
+ size: "small",
9
14
  languages: "about 100 languages, Russian and English among them",
10
15
  licence: "MIT",
11
16
  dims: 384,
@@ -39,6 +44,7 @@ export const TEXT_MODELS = [
39
44
  {
40
45
  id: "embeddinggemma",
41
46
  title: "EmbeddingGemma 300M, 4-bit",
47
+ size: "medium",
42
48
  languages: "over 100 languages — the best of the two on chat, about seven times slower",
43
49
  licence: "Gemma Terms of Use",
44
50
  terms: "https://ai.google.dev/gemma/terms",
@@ -76,15 +82,117 @@ export const TEXT_MODELS = [
76
82
  },
77
83
  ],
78
84
  },
85
+ {
86
+ id: "e5-large",
87
+ title: "multilingual-e5-large, 8-bit",
88
+ size: "large",
89
+ languages: "about 100 languages, Russian and English among them — reads better than e5-small, several times slower",
90
+ licence: "MIT",
91
+ dims: 1024,
92
+ maxTokens: 512,
93
+ // 2026-11-07, one 8-thread session on the Ryzen AI 9 HX 470 while other benchmarks ran: 3.4 chunks/s.
94
+ chunksPerSecond: 4,
95
+ pooling: "mean",
96
+ prefix: { query: "query: ", passage: "passage: " },
97
+ onnx: "onnx/model_quantized.onnx",
98
+ files: [
99
+ {
100
+ name: "onnx/model_quantized.onnx",
101
+ url: e5Large("onnx/model_quantized.onnx"),
102
+ sha256: "0a8d65db9a36f810ba5da15249f13145fcdc7890e6656f1fd38cd8b7c4db1fca",
103
+ bytes: 561_768_762,
104
+ },
105
+ {
106
+ name: "tokenizer.json",
107
+ url: e5Large("tokenizer.json"),
108
+ sha256: "62c24cdc13d4c9952d63718d6c9fa4c287974249e16b7ade6d5a85e7bbb75626",
109
+ bytes: 17_082_660,
110
+ },
111
+ {
112
+ name: "tokenizer_config.json",
113
+ url: e5Large("tokenizer_config.json"),
114
+ sha256: "efb5c0d09722e5fe59a462cd2a9976ee216d55b037597d997cd3fe833216da15",
115
+ bytes: 418,
116
+ },
117
+ ],
118
+ },
79
119
  ];
80
120
  export const DEFAULT_TEXT_MODEL = "e5-small";
81
- export const textModel = (id) => {
82
- const found = TEXT_MODELS.find((model) => model.id === id);
121
+ const SECTION = "text_models";
122
+ const slug = v.pipe(v.string(), v.regex(/^[a-z0-9][a-z0-9._-]{0,62}$/, "is not a model id: a-z, 0-9, . _ -"));
123
+ const words = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(300));
124
+ /** Joined under the model's folder: never absolute, never climbing out of it. */
125
+ const fileName = v.pipe(v.string(), v.check((name) => /^[\w.-]+(\/[\w.-]+)*$/.test(name) && !name.split("/").some((part) => part === ".." || part === "."), "is not a file inside the model's folder"));
126
+ const modelFile = v.strictObject({
127
+ name: fileName,
128
+ url: v.pipe(v.string(), v.url(), v.startsWith("https://", "has to be an https address")),
129
+ sha256: v.pipe(v.string(), v.regex(/^[0-9a-f]{64}$/, "has to be a sha256 in hex")),
130
+ bytes: v.pipe(v.number(), v.integer(), v.minValue(1)),
131
+ });
132
+ /** A model the owner adds: the same shape as a built-in one, so it is downloaded, checked and loaded the same way. */
133
+ export const CustomTextModelShape = v.pipe(v.strictObject({
134
+ id: slug,
135
+ title: words,
136
+ languages: words,
137
+ licence: words,
138
+ terms: v.optional(v.pipe(v.string(), v.url())),
139
+ dims: v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(8192)),
140
+ maxTokens: v.pipe(v.number(), v.integer(), v.minValue(16), v.maxValue(32_768)),
141
+ chunksPerSecond: v.optional(v.pipe(v.number(), v.minValue(0.01))),
142
+ pooling: v.picklist(["mean", "sentence_embedding"]),
143
+ prefix: v.strictObject({
144
+ query: v.pipe(v.string(), v.maxLength(200)),
145
+ passage: v.pipe(v.string(), v.maxLength(200)),
146
+ }),
147
+ onnx: fileName,
148
+ externalData: v.optional(fileName),
149
+ files: v.pipe(v.array(modelFile), v.minLength(1), v.maxLength(16)),
150
+ }), v.check((model) => !TEXT_MODELS.some((one) => one.id === model.id), "takes the id of a model this version ships; choose another"), v.check((model) => {
151
+ const names = model.files.map(({ name }) => name);
152
+ return [model.onnx, model.externalData, "tokenizer.json", "tokenizer_config.json"].every((name) => name === undefined || names.includes(name));
153
+ }, "has to list its onnx file, its external data and tokenizer.json and tokenizer_config.json among files"));
154
+ const TextModelsSection = v.strictObject({
155
+ use: v.optional(slug),
156
+ custom: v.optional(v.array(CustomTextModelShape)),
157
+ });
158
+ /** The shared settings file every WireCat CLI reads, so one choice serves tg, MAX, memo and the rest. */
159
+ export const textModelsFile = (env = process.env) => sharedConfigPath(storePath(env), env);
160
+ export const readTextModelsSection = (env = process.env) => {
161
+ const path = textModelsFile(env);
162
+ const section = readSharedSection(path, SECTION);
163
+ if (section === undefined)
164
+ return {};
165
+ const checked = v.safeParse(TextModelsSection, section);
166
+ if (!checked.success) {
167
+ const issue = checked.issues[0];
168
+ const at = issue ? v.getDotPath(issue) : null;
169
+ throw new CliError("configuration_error", `${path}: ${SECTION}${at ? `.${at}` : ""} ${issue?.message ?? "is not valid"}`);
170
+ }
171
+ const ids = checked.output.custom?.map(({ id }) => id) ?? [];
172
+ const twice = ids.find((id, at) => ids.indexOf(id) !== at);
173
+ if (twice)
174
+ throw new CliError("configuration_error", `${path}: ${SECTION}.custom names ${twice} twice`);
175
+ return checked.output;
176
+ };
177
+ export const writeTextModelsSection = (section, env = process.env) => writeSharedSection(textModelsFile(env), SECTION, section.use === undefined && !section.custom?.length ? undefined : section);
178
+ /** The models this version ships, then the owner's own. */
179
+ export const textModels = (env = process.env) => [
180
+ ...TEXT_MODELS,
181
+ ...(readTextModelsSection(env).custom ?? []).map((model) => ({ ...model, custom: true })),
182
+ ];
183
+ export const textModel = (id, env = process.env) => {
184
+ const known = textModels(env);
185
+ const found = known.find((model) => model.id === id);
83
186
  if (!found) {
84
- throw new CliError("validation_error", `no text model ${id} — one of: ${TEXT_MODELS.map((model) => model.id).join(", ")}`);
187
+ throw new CliError("validation_error", `no text model ${id} — one of: ${known.map((model) => model.id).join(", ")}`);
85
188
  }
86
189
  return found;
87
190
  };
191
+ /** The model every embed and every search by meaning uses when none is named: the owner's `models use`, or e5-small. */
192
+ export const chosenTextModel = (env = process.env) => {
193
+ const use = readTextModelsSection(env).use;
194
+ return use === undefined ? { id: DEFAULT_TEXT_MODEL, from: "default" } : { id: use, from: "chosen" };
195
+ };
88
196
  const mmarco = huggingFace("cross-encoder/mmarco-mMiniLMv2-L12-H384-v1", "1427fd652930e4ba29e8149678df786c240d8825");
89
197
  const bge = huggingFace("onnx-community/bge-reranker-v2-m3-ONNX", "6f5ff65298512715a1e669753bc754d2bc8f367b");
90
198
  export const RERANK_MODELS = [
@@ -154,7 +262,13 @@ export const rerankModel = (id) => {
154
262
  }
155
263
  return found;
156
264
  };
265
+ /**
266
+ * A vector's model: the provider, the model and its size — vectors of two of them never mix. A custom model's key also
267
+ * carries its weights' hash, so an id the owner redefines as another model starts from no vectors.
268
+ */
269
+ export const vectorModelKey = (model) => {
270
+ const weights = model.custom ? model.files.find(({ name }) => name === model.onnx)?.sha256.slice(0, 12) : undefined;
271
+ return `local:${model.id}${weights ? `@${weights}` : ""}:${model.dims}`;
272
+ };
157
273
  /** The cosine a meaning hit must beat, measured in bench/search-quality; an unmeasured model keeps every hit. */
158
- /** A vector's model: the provider, the model and its size — vectors of two of them never mix. */
159
- export const vectorModelKey = (model) => `local:${model.id}:${model.dims}`;
160
274
  export const meaningFloor = (key) => (key === "local:e5-small:384" ? 0.8 : 0);
@@ -1,7 +1,10 @@
1
1
  import * as v from "valibot";
2
- /** One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal or a lead. */
2
+ /**
3
+ * One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead, or an
4
+ * invoice, payment, order, contract, subscription, product or wallet.
5
+ */
3
6
  export declare const hit: v.StrictObjectSchema<{
4
- readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead"], undefined>;
7
+ readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
5
8
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
6
9
  readonly provider: v.StringSchema<undefined>;
7
10
  readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -31,6 +34,14 @@ export declare const hit: v.StrictObjectSchema<{
31
34
  readonly lines_total: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
32
35
  /** A meeting passage's stored line, so two passages of one meeting stay apart; `search meetings` gives the same. */
33
36
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
37
+ /** A business hit's: `proposed` waits for the owner; a product or a wallet has no review and is `confirmed`. */
38
+ readonly review: v.OptionalSchema<v.PicklistSchema<["proposed", "confirmed"], undefined>, undefined>;
39
+ /** A business hit's record in the import that made it; absent for one the owner or an agent wrote. */
40
+ readonly source_record: v.OptionalSchema<v.StrictObjectSchema<{
41
+ readonly provider: v.StringSchema<undefined>;
42
+ readonly account: v.StringSchema<undefined>;
43
+ readonly external_id: v.StringSchema<undefined>;
44
+ }, undefined>, undefined>;
34
45
  /** A message's files; absent when it has none. */
35
46
  readonly attachments: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
36
47
  readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -1,9 +1,13 @@
1
1
  import * as v from "valibot";
2
+ import { BUSINESS_KINDS } from "../domain/business.js";
2
3
  import { hitFile } from "./attachment.js";
3
4
  import { count, reference, text, time, untrusted } from "./fields.js";
4
- /** One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal or a lead. */
5
+ /**
6
+ * One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead, or an
7
+ * invoice, payment, order, contract, subscription, product or wallet.
8
+ */
5
9
  export const hit = v.strictObject({
6
- kind: v.picklist(["message", "mail", "note", "document", "event", "meeting", "deal", "lead"]),
10
+ kind: v.picklist(["message", "mail", "note", "document", "event", "meeting", "deal", "lead", ...BUSINESS_KINDS]),
7
11
  ref: reference,
8
12
  provider: text,
9
13
  url: v.optional(text),
@@ -33,6 +37,10 @@ export const hit = v.strictObject({
33
37
  lines_total: v.optional(count),
34
38
  /** A meeting passage's stored line, so two passages of one meeting stay apart; `search meetings` gives the same. */
35
39
  id: v.optional(v.pipe(v.string(), v.minLength(1))),
40
+ /** A business hit's: `proposed` waits for the owner; a product or a wallet has no review and is `confirmed`. */
41
+ review: v.optional(v.picklist(["proposed", "confirmed"])),
42
+ /** A business hit's record in the import that made it; absent for one the owner or an agent wrote. */
43
+ source_record: v.optional(v.strictObject({ provider: text, account: text, external_id: text })),
36
44
  /** A message's files; absent when it has none. */
37
45
  attachments: v.optional(v.array(hitFile)),
38
46
  /** Absent on a note hit: the owner wrote it. */
@@ -4261,7 +4261,7 @@ export declare const ENTITIES: {
4261
4261
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
4262
4262
  }, undefined>;
4263
4263
  readonly hit: v.StrictObjectSchema<{
4264
- readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead"], undefined>;
4264
+ readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
4265
4265
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4266
4266
  readonly provider: v.StringSchema<undefined>;
4267
4267
  readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -4280,6 +4280,12 @@ export declare const ENTITIES: {
4280
4280
  readonly line: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>]>, undefined>;
4281
4281
  readonly lines_total: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
4282
4282
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
4283
+ readonly review: v.OptionalSchema<v.PicklistSchema<["proposed", "confirmed"], undefined>, undefined>;
4284
+ readonly source_record: v.OptionalSchema<v.StrictObjectSchema<{
4285
+ readonly provider: v.StringSchema<undefined>;
4286
+ readonly account: v.StringSchema<undefined>;
4287
+ readonly external_id: v.StringSchema<undefined>;
4288
+ }, undefined>, undefined>;
4283
4289
  readonly attachments: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
4284
4290
  readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
4285
4291
  readonly kind: v.StringSchema<undefined>;
@@ -9931,6 +9937,11 @@ export declare const ENTITIES: {
9931
9937
  readonly title: v.StringSchema<undefined>;
9932
9938
  readonly languages: v.StringSchema<undefined>;
9933
9939
  readonly licence: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
9940
+ readonly terms: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
9941
+ readonly size: v.OptionalSchema<v.PicklistSchema<["small", "medium", "large"], undefined>, undefined>;
9942
+ readonly dims: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
9943
+ readonly chunks_per_second: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
9944
+ readonly custom: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
9934
9945
  readonly size_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
9935
9946
  readonly downloaded: v.BooleanSchema<undefined>;
9936
9947
  readonly default: v.BooleanSchema<undefined>;
@@ -10211,6 +10222,25 @@ export declare const ENTITIES: {
10211
10222
  readonly command: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
10212
10223
  }, undefined>, undefined>;
10213
10224
  }, undefined>;
10225
+ readonly "model.chosen": v.StrictObjectSchema<{
10226
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
10227
+ readonly kind: v.PicklistSchema<["audio", "text", "image", "reranker"], undefined>;
10228
+ readonly title: v.StringSchema<undefined>;
10229
+ readonly languages: v.StringSchema<undefined>;
10230
+ readonly licence: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
10231
+ readonly terms: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
10232
+ readonly size: v.OptionalSchema<v.PicklistSchema<["small", "medium", "large"], undefined>, undefined>;
10233
+ readonly dims: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
10234
+ readonly chunks_per_second: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
10235
+ readonly custom: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
10236
+ readonly size_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
10237
+ readonly downloaded: v.BooleanSchema<undefined>;
10238
+ readonly default: v.BooleanSchema<undefined>;
10239
+ readonly path: v.StringSchema<undefined>;
10240
+ readonly previous: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
10241
+ readonly to_embed: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
10242
+ readonly estimate_seconds: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
10243
+ }, undefined>;
10214
10244
  readonly model_key: v.StrictObjectSchema<{
10215
10245
  readonly provider: v.StringSchema<undefined>;
10216
10246
  readonly stored: v.OptionalSchema<v.PicklistSchema<["environment", "keyring", "file"], undefined>, undefined>;
@@ -66,7 +66,7 @@ import { messageLink } from "./message-link.js";
66
66
  import { evidencePacket, messageLinks, messageTranscript } from "./message-read.js";
67
67
  import { messageDownload, messageSync } from "./message-transfer.js";
68
68
  import { messageSend, messageWrite } from "./message-write.js";
69
- import { model } from "./model.js";
69
+ import { chosenModel, model } from "./model.js";
70
70
  import { modelKey, removedModelKey, storedModelKey } from "./model-key.js";
71
71
  import { note } from "./note.js";
72
72
  import { officialStats } from "./official-stats.js";
@@ -340,6 +340,7 @@ export const ENTITIES = {
340
340
  chat_folder_order: chatFolderOrder,
341
341
  chat_rules: chatRules,
342
342
  chat_moderation: chatModeration,
343
+ "model.chosen": chosenModel,
343
344
  model_key: modelKey,
344
345
  "model_key.stored": storedModelKey,
345
346
  "model_key.removed": removedModelKey,
@@ -10,11 +10,52 @@ export declare const model: v.StrictObjectSchema<{
10
10
  /** Which languages it reads, in words. */
11
11
  readonly languages: v.StringSchema<undefined>;
12
12
  readonly licence: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
13
+ /** A text model's licence terms to accept with `models download --accept-terms`. */
14
+ readonly terms: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
15
+ /** A text model's size next to the others: small is fastest, large reads best. */
16
+ readonly size: v.OptionalSchema<v.PicklistSchema<["small", "medium", "large"], undefined>, undefined>;
17
+ /** A text model's vector length. */
18
+ readonly dims: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
19
+ /** About how many chunks a second a text model embeds here, when measured. */
20
+ readonly chunks_per_second: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
21
+ /** A text model the owner added with `models add`. */
22
+ readonly custom: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
13
23
  /** What its files take on disk once downloaded. */
14
24
  readonly size_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
15
25
  readonly downloaded: v.BooleanSchema<undefined>;
16
- /** The one used when no model is named. */
26
+ /** The one used when no model is named: for text, the one `models use` chose. */
17
27
  readonly default: v.BooleanSchema<undefined>;
18
28
  /** The folder its files are in once downloaded, so an agent can place them by hand. */
19
29
  readonly path: v.StringSchema<undefined>;
20
30
  }, undefined>;
31
+ /** `models set`: the model now in use, the one before it, and what the next syncs still embed with it. */
32
+ export declare const chosenModel: v.StrictObjectSchema<{
33
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
34
+ readonly kind: v.PicklistSchema<["audio", "text", "image", "reranker"], undefined>;
35
+ readonly title: v.StringSchema<undefined>;
36
+ /** Which languages it reads, in words. */
37
+ readonly languages: v.StringSchema<undefined>;
38
+ readonly licence: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
39
+ /** A text model's licence terms to accept with `models download --accept-terms`. */
40
+ readonly terms: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
41
+ /** A text model's size next to the others: small is fastest, large reads best. */
42
+ readonly size: v.OptionalSchema<v.PicklistSchema<["small", "medium", "large"], undefined>, undefined>;
43
+ /** A text model's vector length. */
44
+ readonly dims: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
45
+ /** About how many chunks a second a text model embeds here, when measured. */
46
+ readonly chunks_per_second: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
47
+ /** A text model the owner added with `models add`. */
48
+ readonly custom: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
49
+ /** What its files take on disk once downloaded. */
50
+ readonly size_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
51
+ readonly downloaded: v.BooleanSchema<undefined>;
52
+ /** The one used when no model is named: for text, the one `models use` chose. */
53
+ readonly default: v.BooleanSchema<undefined>;
54
+ /** The folder its files are in once downloaded, so an agent can place them by hand. */
55
+ readonly path: v.StringSchema<undefined>;
56
+ readonly previous: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
57
+ /** Chunk texts the previous model has vectors for and this one has not; `null` when no store is there to count. */
58
+ readonly to_embed: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
59
+ /** Embedding time alone at the model's speed, done a part per sync; `null` when the speed or the count is unknown. */
60
+ readonly estimate_seconds: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
61
+ }, undefined>;
@@ -11,11 +11,30 @@ export const model = v.strictObject({
11
11
  /** Which languages it reads, in words. */
12
12
  languages: text,
13
13
  licence: v.optional(text),
14
+ /** A text model's licence terms to accept with `models download --accept-terms`. */
15
+ terms: v.optional(text),
16
+ /** A text model's size next to the others: small is fastest, large reads best. */
17
+ size: v.optional(v.picklist(["small", "medium", "large"])),
18
+ /** A text model's vector length. */
19
+ dims: v.optional(count),
20
+ /** About how many chunks a second a text model embeds here, when measured. */
21
+ chunks_per_second: v.optional(v.number()),
22
+ /** A text model the owner added with `models add`. */
23
+ custom: v.optional(v.boolean()),
14
24
  /** What its files take on disk once downloaded. */
15
25
  size_bytes: count,
16
26
  downloaded: v.boolean(),
17
- /** The one used when no model is named. */
27
+ /** The one used when no model is named: for text, the one `models use` chose. */
18
28
  default: v.boolean(),
19
29
  /** The folder its files are in once downloaded, so an agent can place them by hand. */
20
30
  path: text,
21
31
  });
32
+ /** `models set`: the model now in use, the one before it, and what the next syncs still embed with it. */
33
+ export const chosenModel = v.strictObject({
34
+ ...model.entries,
35
+ previous: id,
36
+ /** Chunk texts the previous model has vectors for and this one has not; `null` when no store is there to count. */
37
+ to_embed: v.nullable(count),
38
+ /** Embedding time alone at the model's speed, done a part per sync; `null` when the speed or the count is unknown. */
39
+ estimate_seconds: v.nullable(count),
40
+ });
@@ -211,6 +211,7 @@ const OTHERS = [
211
211
  validation("evidence.row-too-large", "one evidence row is over its size limit"),
212
212
  validation("index.not-ready", "the search index is still being built"),
213
213
  validation("input.closed", "the input closed before the answer"),
214
+ validation("input.empty", "a hidden prompt got an empty answer three times"),
214
215
  validation("input.required", "the command needs an answer and cannot ask for one"),
215
216
  validation("input.too-large", "the input is over its size limit"),
216
217
  ["meeting-project.stale", "configuration_error", "the meeting's project changed meanwhile"],
@@ -219,10 +220,13 @@ const OTHERS = [
219
220
  validation("fact.payment-retired", "a payment is a payments row in store.finance, not a fact"),
220
221
  validation("fact.revoke-correction", "an accepted correction cannot be revoked; its superseded fact stays"),
221
222
  validation("finance.allocate", "the invoice or payment cannot take an allocation in its state"),
223
+ validation("finance.below-paid", "the invoice's lines would total less than is paid on it"),
222
224
  validation("finance.currency", "the payment and the invoice are in different currencies; nothing is converted"),
223
225
  validation("finance.field", "a field of the invoice or payment is not valid"),
224
226
  validation("finance.line-amount", "an invoice line's amount is not its quantity times its unit price"),
227
+ validation("finance.line", "an invoice keeps at least one line: reject or void it instead"),
225
228
  validation("finance.lines", "the invoice's lines are not valid"),
229
+ ["finance.no-line", "not_found", "the invoice has no line at that position"],
226
230
  ["finance.not-allocated", "not_found", "the payment is not allocated to that invoice"],
227
231
  validation("finance.over-invoice", "the allocation would settle more than the invoice's total"),
228
232
  validation("finance.over-payment", "the allocation would use more than the payment's amount"),