narrarium-engine 0.1.7 → 0.1.9

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 (132) hide show
  1. package/README.md +360 -26
  2. package/dist/ai/body.d.ts +20 -0
  3. package/dist/ai/body.d.ts.map +1 -0
  4. package/dist/ai/body.js +112 -0
  5. package/dist/ai/body.js.map +1 -0
  6. package/dist/ai/catalog-fetch.d.ts +51 -0
  7. package/dist/ai/catalog-fetch.d.ts.map +1 -0
  8. package/dist/ai/catalog-fetch.js +261 -0
  9. package/dist/ai/catalog-fetch.js.map +1 -0
  10. package/dist/ai/catalog-support.d.ts +13 -0
  11. package/dist/ai/catalog-support.d.ts.map +1 -0
  12. package/dist/ai/catalog-support.js +28 -0
  13. package/dist/ai/catalog-support.js.map +1 -0
  14. package/dist/ai/catalog.d.ts +148 -0
  15. package/dist/ai/catalog.d.ts.map +1 -0
  16. package/dist/ai/catalog.js +367 -0
  17. package/dist/ai/catalog.js.map +1 -0
  18. package/dist/ai/config.d.ts +83 -7
  19. package/dist/ai/config.d.ts.map +1 -1
  20. package/dist/ai/config.js +83 -11
  21. package/dist/ai/config.js.map +1 -1
  22. package/dist/ai/fetch-client.d.ts +20 -0
  23. package/dist/ai/fetch-client.d.ts.map +1 -1
  24. package/dist/ai/fetch-client.js +49 -24
  25. package/dist/ai/fetch-client.js.map +1 -1
  26. package/dist/ai/probe.d.ts +40 -0
  27. package/dist/ai/probe.d.ts.map +1 -0
  28. package/dist/ai/probe.js +110 -0
  29. package/dist/ai/probe.js.map +1 -0
  30. package/dist/ai/request.d.ts +58 -5
  31. package/dist/ai/request.d.ts.map +1 -1
  32. package/dist/ai/request.js +96 -7
  33. package/dist/ai/request.js.map +1 -1
  34. package/dist/ai/router.d.ts +12 -1
  35. package/dist/ai/router.d.ts.map +1 -1
  36. package/dist/ai/router.js +10 -2
  37. package/dist/ai/router.js.map +1 -1
  38. package/dist/ai/routing.d.ts +15 -4
  39. package/dist/ai/routing.d.ts.map +1 -1
  40. package/dist/ai/routing.js +25 -6
  41. package/dist/ai/routing.js.map +1 -1
  42. package/dist/ai/token-limit.d.ts +4 -4
  43. package/dist/ai/token-limit.d.ts.map +1 -1
  44. package/dist/ai/token-limit.js +5 -4
  45. package/dist/ai/token-limit.js.map +1 -1
  46. package/dist/ai/types.d.ts +12 -1
  47. package/dist/ai/types.d.ts.map +1 -1
  48. package/dist/ai/types.js +12 -0
  49. package/dist/ai/types.js.map +1 -1
  50. package/dist/autopilot/errors.d.ts +4 -3
  51. package/dist/autopilot/errors.d.ts.map +1 -1
  52. package/dist/autopilot/errors.js +21 -5
  53. package/dist/autopilot/errors.js.map +1 -1
  54. package/dist/autopilot/frozen.d.ts +169 -0
  55. package/dist/autopilot/frozen.d.ts.map +1 -0
  56. package/dist/autopilot/frozen.js +495 -0
  57. package/dist/autopilot/frozen.js.map +1 -0
  58. package/dist/autopilot/outline-check.d.ts +39 -0
  59. package/dist/autopilot/outline-check.d.ts.map +1 -0
  60. package/dist/autopilot/outline-check.js +81 -0
  61. package/dist/autopilot/outline-check.js.map +1 -0
  62. package/dist/autopilot/planner.d.ts +29 -1
  63. package/dist/autopilot/planner.d.ts.map +1 -1
  64. package/dist/autopilot/planner.js +78 -8
  65. package/dist/autopilot/planner.js.map +1 -1
  66. package/dist/autopilot/profile-check.d.ts +7 -4
  67. package/dist/autopilot/profile-check.d.ts.map +1 -1
  68. package/dist/autopilot/profile-check.js +9 -6
  69. package/dist/autopilot/profile-check.js.map +1 -1
  70. package/dist/autopilot/runner.d.ts +17 -3
  71. package/dist/autopilot/runner.d.ts.map +1 -1
  72. package/dist/autopilot/runner.js +127 -20
  73. package/dist/autopilot/runner.js.map +1 -1
  74. package/dist/autopilot/session.d.ts +34 -1
  75. package/dist/autopilot/session.d.ts.map +1 -1
  76. package/dist/autopilot/session.js +202 -2
  77. package/dist/autopilot/session.js.map +1 -1
  78. package/dist/autopilot/state.d.ts +12 -3
  79. package/dist/autopilot/state.d.ts.map +1 -1
  80. package/dist/autopilot/state.js +203 -12
  81. package/dist/autopilot/state.js.map +1 -1
  82. package/dist/autopilot/tasks.d.ts +14 -2
  83. package/dist/autopilot/tasks.d.ts.map +1 -1
  84. package/dist/autopilot/tasks.js +480 -36
  85. package/dist/autopilot/tasks.js.map +1 -1
  86. package/dist/autopilot/types.d.ts +193 -12
  87. package/dist/autopilot/types.d.ts.map +1 -1
  88. package/dist/autopilot/types.js +9 -2
  89. package/dist/autopilot/types.js.map +1 -1
  90. package/dist/book/context.d.ts +3 -0
  91. package/dist/book/context.d.ts.map +1 -1
  92. package/dist/book/context.js +7 -1
  93. package/dist/book/context.js.map +1 -1
  94. package/dist/book/freeze.d.ts +115 -0
  95. package/dist/book/freeze.d.ts.map +1 -0
  96. package/dist/book/freeze.js +286 -0
  97. package/dist/book/freeze.js.map +1 -0
  98. package/dist/book/outline.d.ts +245 -0
  99. package/dist/book/outline.d.ts.map +1 -0
  100. package/dist/book/outline.js +488 -0
  101. package/dist/book/outline.js.map +1 -0
  102. package/dist/book/paths.d.ts +18 -0
  103. package/dist/book/paths.d.ts.map +1 -1
  104. package/dist/book/paths.js +25 -0
  105. package/dist/book/paths.js.map +1 -1
  106. package/dist/book/snapshot.d.ts +25 -1
  107. package/dist/book/snapshot.d.ts.map +1 -1
  108. package/dist/book/snapshot.js +24 -4
  109. package/dist/book/snapshot.js.map +1 -1
  110. package/dist/director/opinion.d.ts +6 -0
  111. package/dist/director/opinion.d.ts.map +1 -1
  112. package/dist/director/opinion.js +4 -1
  113. package/dist/director/opinion.js.map +1 -1
  114. package/dist/index.d.ts +8 -0
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +8 -0
  117. package/dist/index.js.map +1 -1
  118. package/dist/profiles/evaluation-style.d.ts +44 -0
  119. package/dist/profiles/evaluation-style.d.ts.map +1 -0
  120. package/dist/profiles/evaluation-style.js +152 -0
  121. package/dist/profiles/evaluation-style.js.map +1 -0
  122. package/dist/server/client.d.ts +46 -2
  123. package/dist/server/client.d.ts.map +1 -1
  124. package/dist/server/client.js +57 -0
  125. package/dist/server/client.js.map +1 -1
  126. package/dist/server/protocol.d.ts +120 -2
  127. package/dist/server/protocol.d.ts.map +1 -1
  128. package/dist/server/protocol.js +36 -0
  129. package/dist/server/protocol.js.map +1 -1
  130. package/dist/version.d.ts +1 -1
  131. package/dist/version.js +1 -1
  132. package/package.json +1 -1
@@ -0,0 +1,148 @@
1
+ import type { AiChatModelConfig, AiThinking } from "./config.js";
2
+ /** The most models a list may hold: a longer one is refused (`GET /models`) or cut here (`/models/details`, `/modalities`). */
3
+ export declare const CATALOG_MAX_MODELS = 2000;
4
+ /** The longest id of a model. */
5
+ export declare const CATALOG_MAX_ID_LENGTH = 256;
6
+ /** A window or an answer that is declared is a whole number of tokens within these limits; anything else is not declared. */
7
+ export declare const CATALOG_MIN_TOKENS = 256;
8
+ export declare const CATALOG_MAX_TOKENS = 10000000;
9
+ /** LM Studio's list: how many models and how long a key are read. */
10
+ export declare const LMSTUDIO_MAX_MODELS = 500;
11
+ export declare const LMSTUDIO_MAX_KEY_LENGTH = 200;
12
+ /**
13
+ * Why the models of an endpoint could not be read. `unreachable`: no answer (the server is off, the address is wrong, a redirect was refused, or, in a
14
+ * browser, CORS blocked the request: the browser cannot tell them apart). `timeout`: it did not answer, or stopped answering, in time. `unauthorized`:
15
+ * 401 or 403, the key. `not-found`: 404, no list at this address. `rate-limited`: 429. `server-error`: 5xx. `http-error`: any other status. `invalid`:
16
+ * the answer is not a list of models. `empty`: it is one, and has no model in it. `too-large`: more models, or more bytes, than may be read.
17
+ * `unsupported`: the integration has no list to read (Azure OpenAI, GitHub Models, Microsoft 365).
18
+ */
19
+ export type AiCatalogErrorReason = "unreachable" | "timeout" | "unauthorized" | "not-found" | "rate-limited" | "server-error" | "http-error" | "invalid" | "empty" | "too-large" | "unsupported";
20
+ /**
21
+ * The models of an endpoint could not be read, or what it sent is not a catalog. The message is in English, says why and what to do, and never quotes
22
+ * what the endpoint sent or the key that was used. `status` is the HTTP status, for the reasons that come from one.
23
+ */
24
+ export declare class AiCatalogError extends Error {
25
+ readonly reason: AiCatalogErrorReason;
26
+ readonly status?: number | undefined;
27
+ constructor(message: string, reason: AiCatalogErrorReason, status?: number | undefined);
28
+ }
29
+ /** The kinds of model a gateway tells apart (LlmProxy: `GET /v1/models/details`, `GET /v1/modalities`). */
30
+ export declare const AI_MODEL_TYPES: readonly ["chat", "image", "speech", "transcription", "embedding", "realtime", "classifier"];
31
+ /** A kind of model, or `unknown` for one that is not said or is not one of these. */
32
+ export type AiModelType = (typeof AI_MODEL_TYPES)[number] | "unknown";
33
+ /** What a gateway declares a model can do. A capability that is not said is absent; `false` is what LlmProxy sends for everything its administrator has not declared. */
34
+ export interface AiModelCapabilities {
35
+ streaming?: boolean;
36
+ tools?: boolean;
37
+ vision?: boolean;
38
+ reasoning?: boolean;
39
+ }
40
+ /** One model of an endpoint, as its catalog says it. Every field but `id`, `type` and `capabilities` is absent when it is not declared: never a 0, never a guess. */
41
+ export interface AiModelCatalogEntry {
42
+ id: string;
43
+ type: AiModelType;
44
+ /** The longest prompt plus answer one request may use (`context_window`), in tokens. */
45
+ contextWindow?: number;
46
+ /** The largest answer to ask for (`max_output_tokens`), in tokens. */
47
+ maxOutputTokens?: number;
48
+ /** What the model accepts and returns: short words such as `text`, `image`, `audio`, `embedding`. */
49
+ inputModalities?: string[];
50
+ outputModalities?: string[];
51
+ capabilities: AiModelCapabilities;
52
+ }
53
+ /** The models of one way of use (a type), with what they offer together: one entry of `GET /v1/modalities`. */
54
+ export interface AiModalityGroup {
55
+ type: AiModelType;
56
+ /** The paths this kind of model is called at (`/v1/chat/completions`, `/v1/images/generations`…). */
57
+ endpoints: string[];
58
+ /** What the running models of the type accept and return together. */
59
+ inputModalities?: string[];
60
+ outputModalities?: string[];
61
+ /** How many models run for it, as the gateway counts them; a type that is offered and has nothing running has 0 and no models. */
62
+ modelCount: number;
63
+ models: AiModelCatalogEntry[];
64
+ }
65
+ /**
66
+ * The ids of an OpenAI `GET /models` list, sorted and without repeats. It is all or nothing, as BookWriter reads it: a payload that is not a list, an
67
+ * entry that is not an object with a good id, a list with nothing in it or with more than `CATALOG_MAX_MODELS` models is an `AiCatalogError`, so that
68
+ * an answer that is wrong never replaces a catalog that was right. So is a list that says it goes on (`has_more: true`, the pagination of OpenAI-style
69
+ * lists, which Anthropic's `/v1/models` uses: 20 to a page): its first page is not the catalog, and nothing here follows the pages. The error never
70
+ * quotes the payload.
71
+ */
72
+ export declare function parseModelList(payload: unknown): string[];
73
+ /**
74
+ * The models of LlmProxy's `GET /models/details`, in the order received: for each, its kind, the window and the answer it declares, what it accepts
75
+ * and returns, and what it can do. What is `null`, out of scale, or not what it should be is absent; an entry that cannot be one is left out; at most
76
+ * `CATALOG_MAX_MODELS` entries are read. A payload that is not a list is an `AiCatalogError`; a list with nothing in it is a list with nothing in it.
77
+ */
78
+ export declare function parseModelDetails(payload: unknown): AiModelCatalogEntry[];
79
+ /**
80
+ * What LlmProxy's `GET /modalities` says: for each way of use, in the order the gateway lists them, the paths it is called at, what its models
81
+ * accept and return together, and the models that run for it. A model with no kind of its own is of the kind of its group. At most 32 groups, and
82
+ * `CATALOG_MAX_MODELS` models in each, are read. A payload that is not a list is an `AiCatalogError`.
83
+ */
84
+ export declare function parseModalities(payload: unknown): AiModalityGroup[];
85
+ /** The limits of a model as BookWriter keeps them: `inputTokens` is the window minus the answer, and `outputTokens` the answer. */
86
+ export interface AiTokenLimits {
87
+ inputTokens?: number;
88
+ outputTokens?: number;
89
+ }
90
+ /**
91
+ * BookWriter's formula (`tokenLimitsFromDetails`): the input is the window minus the answer the model declares, or, when it declares none, minus a
92
+ * quarter of the window up to 4096; an answer with no window is only the answer; an answer that is not smaller than its window is not believed; and an
93
+ * input that is not a usable number of tokens (it would be 0 or negative, or under 256) is not said.
94
+ *
95
+ * Mind what it is: BookWriter's `inputTokens` is what is left for the prompt once the answer is taken off. The engine's `maxInputTokens` is the window
96
+ * itself (the engine takes the answer and a safety margin off it when it judges a prompt), so it is the declared `contextWindow` that goes there,
97
+ * never this number: use `modelFieldsFromCatalogEntry`, which does.
98
+ */
99
+ export declare function tokenLimitsFromDetails(entry: Pick<AiModelCatalogEntry, "contextWindow" | "maxOutputTokens"> | null | undefined): AiTokenLimits;
100
+ /** What a catalog entry can fill in a model of the configuration. */
101
+ export type AiCatalogModelFields = Partial<Pick<AiChatModelConfig, "maxInputTokens" | "maxOutputTokens" | "supportsToolCalls" | "supportsStreaming" | "supportsReasoning" | "supportsVision">>;
102
+ /**
103
+ * What a gateway declares of a model, as fields of the model in the configuration, for the models of kind `chat`. Only what is declared is said:
104
+ * the context window is `maxInputTokens` (the window, not BookWriter's input: see `tokenLimitsFromDetails`), the answer is `maxOutputTokens` (when it fits the
105
+ * window), and a capability is said only when it is `true`. A capability that is `false` is what LlmProxy sends for everything its administrator has not
106
+ * declared, so it is never turned into a restriction (a model that streams, with the box not ticked, must go on streaming); and an id that only
107
+ * `/models` listed says nothing at all. The author's own values are kept by the caller: `{ ...model, ...fields }` lets the gateway's declarations win for
108
+ * what it declares, and leaves the rest as it is.
109
+ */
110
+ export declare function modelFieldsFromCatalogEntry(entry: AiModelCatalogEntry): AiCatalogModelFields;
111
+ type ThinkingLevel = Exclude<AiThinking, "automatic">;
112
+ /** The levels of thinking a model allows (in the engine's own order), and the one it uses when none is chosen. */
113
+ export interface AiLmStudioReasoning {
114
+ options: ThinkingLevel[];
115
+ default?: ThinkingLevel;
116
+ }
117
+ /** One language model of LM Studio, as its own list says it. */
118
+ export interface AiLmStudioModel {
119
+ key: string;
120
+ /**
121
+ * The levels of thinking the model declares. `null`: the server says the model has no level to choose (what it allows is not low, medium, high or
122
+ * xhigh). Absent: the server said nothing of reasoning for this model.
123
+ */
124
+ reasoning?: AiLmStudioReasoning | null;
125
+ /** The longest context the model supports. */
126
+ maxContext?: number;
127
+ /** The instances that are loaded now, with the context each was loaded with. */
128
+ loaded: Array<{
129
+ id: string;
130
+ contextLength?: number;
131
+ }>;
132
+ }
133
+ /**
134
+ * The language models (`type: "llm"`) of LM Studio's `GET /api/v1/models`, as BookWriter reads them: the thinking levels each declares
135
+ * (`capabilities.reasoning.allowed_options`, of which only low, medium, high and xhigh are levels), its default, the context it supports and the one
136
+ * it loaded. At most `LMSTUDIO_MAX_MODELS` entries are read. A payload that is not a list of models is an `AiCatalogError`.
137
+ */
138
+ export declare function parseLmStudioModels(payload: unknown): AiLmStudioModel[];
139
+ /**
140
+ * The context of one LM Studio model, found as BookWriter finds it: by its key or by the id of one of its loaded instances; `loaded` is the context
141
+ * of that instance (else of the first one) and `max` the longest the model supports. `undefined` for a model the list does not have.
142
+ */
143
+ export declare function lmStudioContext(models: readonly AiLmStudioModel[], modelId: string): {
144
+ loaded?: number;
145
+ max?: number;
146
+ } | undefined;
147
+ export {};
148
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/ai/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOjE,+HAA+H;AAC/H,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,iCAAiC;AACjC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,6HAA6H;AAC7H,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,kBAAkB,WAAa,CAAC;AAC7C,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAkB3C;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG,SAAS,GAAG,cAAc,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,aAAa,CAAC;AAEjM;;;GAGG;AACH,qBAAa,cAAe,S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AC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,CA8CvE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAWlI"}
@@ -0,0 +1,367 @@
1
+ // What an endpoint says of its models, read from the three places a gateway like LlmProxy says it (and from LM Studio's own list). Pure: no I/O, no clock.
2
+ // Everything that comes in is data from a server nobody vouches for: it is bounded, validated field by field, never trusted for what it is called, and
3
+ // never quoted in an error. The limits are those of BookWriter (`fetchModels` and `tokenLimitsFromDetails`: 2000 models, 256 characters, windows from 256 to
4
+ // 10 000 000 tokens) and, for LM Studio's list, those of its `lmstudio-models.ts` (500 models, 200 characters).
5
+ /** The most models a list may hold: a longer one is refused (`GET /models`) or cut here (`/models/details`, `/modalities`). */
6
+ export const CATALOG_MAX_MODELS = 2_000;
7
+ /** The longest id of a model. */
8
+ export const CATALOG_MAX_ID_LENGTH = 256;
9
+ /** A window or an answer that is declared is a whole number of tokens within these limits; anything else is not declared. */
10
+ export const CATALOG_MIN_TOKENS = 256;
11
+ export const CATALOG_MAX_TOKENS = 10_000_000;
12
+ /** LM Studio's list: how many models and how long a key are read. */
13
+ export const LMSTUDIO_MAX_MODELS = 500;
14
+ export const LMSTUDIO_MAX_KEY_LENGTH = 200;
15
+ const MAX_MODALITY_GROUPS = 32;
16
+ const MAX_MODALITIES = 16;
17
+ const MAX_MODALITY_LENGTH = 32;
18
+ const MAX_ENDPOINTS = 16;
19
+ const MAX_ENDPOINT_LENGTH = 120;
20
+ const MAX_LOADED_INSTANCES = 16;
21
+ const MAX_MODEL_COUNT = 1_000_000;
22
+ /** A list that claims more entries than this is read only as far as it is needed: an array this long costs nothing to ask for its length, and a lot to walk. */
23
+ const MAX_WALKED = 4 * CATALOG_MAX_MODELS;
24
+ const FORBIDDEN = new Set(["__proto__", "constructor", "prototype"]);
25
+ const CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
26
+ const MODALITY_WORD = /^[a-z0-9_-]{1,32}$/;
27
+ /**
28
+ * The models of an endpoint could not be read, or what it sent is not a catalog. The message is in English, says why and what to do, and never quotes
29
+ * what the endpoint sent or the key that was used. `status` is the HTTP status, for the reasons that come from one.
30
+ */
31
+ export class AiCatalogError extends Error {
32
+ reason;
33
+ status;
34
+ constructor(message, reason, status) {
35
+ super(message);
36
+ this.reason = reason;
37
+ this.status = status;
38
+ this.name = "AiCatalogError";
39
+ }
40
+ }
41
+ const NOT_A_LIST = "The answer is not a list of models in the OpenAI format ({\"data\": [{\"id\": …}]}). Check that the address is the API base (for example …/v1), or enter the model names by hand.";
42
+ const EMPTY_LIST = "The list of models is empty. If this is a gateway, start a model there (a model that is stopped is not listed), or enter the model names by hand.";
43
+ const LONG_LIST = `The list has more than ${CATALOG_MAX_MODELS} models: it is too large to be read. Enter the model names by hand.`;
44
+ const PAGED_LIST = "The list of models comes in pages and only the first one was sent, so it cannot be read whole. Enter the model names by hand.";
45
+ const invalid = () => new AiCatalogError(NOT_A_LIST, "invalid");
46
+ // ─── Reading what is untrusted ──────────────────────────────────────────────
47
+ function isRecord(value) {
48
+ return typeof value === "object" && value !== null && !Array.isArray(value);
49
+ }
50
+ /** An id as it is kept: a text with no spaces at its edges, no control character, not too long, and not the name of a prototype. */
51
+ function validId(value, longest = CATALOG_MAX_ID_LENGTH) {
52
+ return typeof value === "string" && value.length > 0 && value.length <= longest && value === value.trim() && !CONTROL.test(value) && !FORBIDDEN.has(value);
53
+ }
54
+ function tokenCount(value) {
55
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= CATALOG_MIN_TOKENS && value <= CATALOG_MAX_TOKENS ? value : undefined;
56
+ }
57
+ /** The `data` of a list as OpenAI writes it. Anything that is not an object with an array in it is not a list. */
58
+ function listOf(payload) {
59
+ if (!isRecord(payload))
60
+ throw invalid();
61
+ const data = payload.data;
62
+ if (!Array.isArray(data))
63
+ throw invalid();
64
+ return data;
65
+ }
66
+ /** Runs a parser of one entry: whatever the entry is (a proxy, a getter that throws), the answer is "it is not an entry". */
67
+ function guarded(read) {
68
+ try {
69
+ return read();
70
+ }
71
+ catch {
72
+ return undefined;
73
+ }
74
+ }
75
+ // ─── What a model is ────────────────────────────────────────────────────────
76
+ /** The kinds of model a gateway tells apart (LlmProxy: `GET /v1/models/details`, `GET /v1/modalities`). */
77
+ export const AI_MODEL_TYPES = ["chat", "image", "speech", "transcription", "embedding", "realtime", "classifier"];
78
+ function typeOf(value) {
79
+ if (typeof value !== "string")
80
+ return "unknown";
81
+ const word = value.trim().toLowerCase();
82
+ return AI_MODEL_TYPES.includes(word) ? word : "unknown";
83
+ }
84
+ /** A list of modalities: short lower-case words, a few of them, each once. `undefined` when there is none. */
85
+ function modalitiesOf(value) {
86
+ if (!Array.isArray(value))
87
+ return undefined;
88
+ const words = [];
89
+ for (let index = 0; index < Math.min(value.length, MAX_WALKED) && words.length < MAX_MODALITIES; index += 1) {
90
+ const raw = value[index];
91
+ if (typeof raw !== "string")
92
+ continue;
93
+ const word = raw.trim().toLowerCase();
94
+ if (MODALITY_WORD.test(word) && word.length <= MAX_MODALITY_LENGTH && !FORBIDDEN.has(word) && !words.includes(word))
95
+ words.push(word);
96
+ }
97
+ return words.length ? words : undefined;
98
+ }
99
+ /** The paths a type of model is called at: short, starting with a slash, no space or control character, a few of them, each once. */
100
+ function endpointsOf(value) {
101
+ if (!Array.isArray(value))
102
+ return [];
103
+ const paths = [];
104
+ for (let index = 0; index < Math.min(value.length, MAX_WALKED) && paths.length < MAX_ENDPOINTS; index += 1) {
105
+ const raw = value[index];
106
+ if (typeof raw === "string" && raw.startsWith("/") && raw.length <= MAX_ENDPOINT_LENGTH && !/[\s\u0000-\u001f\u007f-\u009f]/.test(raw) && !paths.includes(raw))
107
+ paths.push(raw);
108
+ }
109
+ return paths;
110
+ }
111
+ function capabilitiesOf(value) {
112
+ if (!isRecord(value))
113
+ return {};
114
+ const streaming = value.streaming;
115
+ const tools = value.tools;
116
+ const vision = value.vision;
117
+ const reasoning = value.reasoning;
118
+ return {
119
+ ...(typeof streaming === "boolean" ? { streaming } : {}),
120
+ ...(typeof tools === "boolean" ? { tools } : {}),
121
+ ...(typeof vision === "boolean" ? { vision } : {}),
122
+ ...(typeof reasoning === "boolean" ? { reasoning } : {}),
123
+ };
124
+ }
125
+ /** One entry of `/models/details`, or of a `/modalities` group (whose type a model without one takes). */
126
+ function entryOf(raw, groupType) {
127
+ if (!isRecord(raw))
128
+ return undefined;
129
+ const id = raw.id;
130
+ if (!validId(id))
131
+ return undefined;
132
+ const own = typeOf(raw.type);
133
+ const type = own === "unknown" && groupType ? groupType : own;
134
+ const contextWindow = tokenCount(raw.context_window);
135
+ const maxOutputTokens = tokenCount(raw.max_output_tokens);
136
+ const inputModalities = modalitiesOf(raw.input_modalities);
137
+ const outputModalities = modalitiesOf(raw.output_modalities);
138
+ return {
139
+ id,
140
+ type,
141
+ ...(contextWindow !== undefined ? { contextWindow } : {}),
142
+ ...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
143
+ ...(inputModalities ? { inputModalities } : {}),
144
+ ...(outputModalities ? { outputModalities } : {}),
145
+ capabilities: capabilitiesOf(raw.capabilities),
146
+ };
147
+ }
148
+ /** The entries of a list, the first of each id, at most `CATALOG_MAX_MODELS` of the entries that were sent. What is no entry is left out. */
149
+ function entriesOf(data, groupType) {
150
+ const entries = [];
151
+ if (!Array.isArray(data))
152
+ return entries;
153
+ const seen = new Set();
154
+ for (let index = 0; index < Math.min(data.length, CATALOG_MAX_MODELS); index += 1) {
155
+ const entry = guarded(() => entryOf(data[index], groupType));
156
+ if (!entry || seen.has(entry.id))
157
+ continue;
158
+ seen.add(entry.id);
159
+ entries.push(entry);
160
+ }
161
+ return entries;
162
+ }
163
+ // ─── GET /models ────────────────────────────────────────────────────────────
164
+ /**
165
+ * The ids of an OpenAI `GET /models` list, sorted and without repeats. It is all or nothing, as BookWriter reads it: a payload that is not a list, an
166
+ * entry that is not an object with a good id, a list with nothing in it or with more than `CATALOG_MAX_MODELS` models is an `AiCatalogError`, so that
167
+ * an answer that is wrong never replaces a catalog that was right. So is a list that says it goes on (`has_more: true`, the pagination of OpenAI-style
168
+ * lists, which Anthropic's `/v1/models` uses: 20 to a page): its first page is not the catalog, and nothing here follows the pages. The error never
169
+ * quotes the payload.
170
+ */
171
+ export function parseModelList(payload) {
172
+ try {
173
+ const data = listOf(payload);
174
+ if (payload.has_more === true)
175
+ throw new AiCatalogError(PAGED_LIST, "too-large");
176
+ if (data.length === 0)
177
+ throw new AiCatalogError(EMPTY_LIST, "empty");
178
+ if (data.length > CATALOG_MAX_MODELS)
179
+ throw new AiCatalogError(LONG_LIST, "too-large");
180
+ const ids = new Set();
181
+ for (const entry of data) {
182
+ const id = isRecord(entry) ? entry.id : undefined;
183
+ if (!validId(id))
184
+ throw invalid();
185
+ ids.add(id);
186
+ }
187
+ return [...ids].sort();
188
+ }
189
+ catch (error) {
190
+ throw error instanceof AiCatalogError ? error : invalid();
191
+ }
192
+ }
193
+ // ─── GET /models/details ────────────────────────────────────────────────────
194
+ /**
195
+ * The models of LlmProxy's `GET /models/details`, in the order received: for each, its kind, the window and the answer it declares, what it accepts
196
+ * and returns, and what it can do. What is `null`, out of scale, or not what it should be is absent; an entry that cannot be one is left out; at most
197
+ * `CATALOG_MAX_MODELS` entries are read. A payload that is not a list is an `AiCatalogError`; a list with nothing in it is a list with nothing in it.
198
+ */
199
+ export function parseModelDetails(payload) {
200
+ let data;
201
+ try {
202
+ data = listOf(payload);
203
+ }
204
+ catch {
205
+ throw invalid();
206
+ }
207
+ return entriesOf(data);
208
+ }
209
+ // ─── GET /modalities ────────────────────────────────────────────────────────
210
+ /**
211
+ * What LlmProxy's `GET /modalities` says: for each way of use, in the order the gateway lists them, the paths it is called at, what its models
212
+ * accept and return together, and the models that run for it. A model with no kind of its own is of the kind of its group. At most 32 groups, and
213
+ * `CATALOG_MAX_MODELS` models in each, are read. A payload that is not a list is an `AiCatalogError`.
214
+ */
215
+ export function parseModalities(payload) {
216
+ let data;
217
+ try {
218
+ data = listOf(payload);
219
+ }
220
+ catch {
221
+ throw invalid();
222
+ }
223
+ const groups = [];
224
+ for (let index = 0; index < Math.min(data.length, MAX_WALKED) && groups.length < MAX_MODALITY_GROUPS; index += 1) {
225
+ const group = guarded(() => {
226
+ const raw = data[index];
227
+ if (!isRecord(raw))
228
+ return undefined;
229
+ const type = typeOf(raw.type);
230
+ const models = entriesOf(raw.models, type);
231
+ const count = raw.model_count;
232
+ const modelCount = typeof count === "number" && Number.isSafeInteger(count) && count >= 0 && count <= MAX_MODEL_COUNT ? count : models.length;
233
+ const inputModalities = modalitiesOf(raw.input_modalities);
234
+ const outputModalities = modalitiesOf(raw.output_modalities);
235
+ return {
236
+ type,
237
+ endpoints: endpointsOf(raw.endpoints),
238
+ ...(inputModalities ? { inputModalities } : {}),
239
+ ...(outputModalities ? { outputModalities } : {}),
240
+ modelCount,
241
+ models,
242
+ };
243
+ });
244
+ if (group)
245
+ groups.push(group);
246
+ }
247
+ return groups;
248
+ }
249
+ /**
250
+ * BookWriter's formula (`tokenLimitsFromDetails`): the input is the window minus the answer the model declares, or, when it declares none, minus a
251
+ * quarter of the window up to 4096; an answer with no window is only the answer; an answer that is not smaller than its window is not believed; and an
252
+ * input that is not a usable number of tokens (it would be 0 or negative, or under 256) is not said.
253
+ *
254
+ * Mind what it is: BookWriter's `inputTokens` is what is left for the prompt once the answer is taken off. The engine's `maxInputTokens` is the window
255
+ * itself (the engine takes the answer and a safety margin off it when it judges a prompt), so it is the declared `contextWindow` that goes there,
256
+ * never this number: use `modelFieldsFromCatalogEntry`, which does.
257
+ */
258
+ export function tokenLimitsFromDetails(entry) {
259
+ const source = isRecord(entry) ? entry : {};
260
+ const window = tokenCount(source.contextWindow);
261
+ const answer = tokenCount(source.maxOutputTokens);
262
+ const output = answer !== undefined && (window === undefined || answer < window) ? answer : undefined;
263
+ const input = window === undefined ? undefined : window - (output ?? Math.min(4096, Math.floor(window / 4)));
264
+ return {
265
+ ...(input !== undefined && tokenCount(input) !== undefined ? { inputTokens: input } : {}),
266
+ ...(output !== undefined ? { outputTokens: output } : {}),
267
+ };
268
+ }
269
+ /**
270
+ * What a gateway declares of a model, as fields of the model in the configuration, for the models of kind `chat`. Only what is declared is said:
271
+ * the context window is `maxInputTokens` (the window, not BookWriter's input: see `tokenLimitsFromDetails`), the answer is `maxOutputTokens` (when it fits the
272
+ * window), and a capability is said only when it is `true`. A capability that is `false` is what LlmProxy sends for everything its administrator has not
273
+ * declared, so it is never turned into a restriction (a model that streams, with the box not ticked, must go on streaming); and an id that only
274
+ * `/models` listed says nothing at all. The author's own values are kept by the caller: `{ ...model, ...fields }` lets the gateway's declarations win for
275
+ * what it declares, and leaves the rest as it is.
276
+ */
277
+ export function modelFieldsFromCatalogEntry(entry) {
278
+ const source = isRecord(entry) ? entry : {};
279
+ const window = tokenCount(source.contextWindow);
280
+ const { outputTokens } = tokenLimitsFromDetails(entry);
281
+ const capabilities = capabilitiesOf(source.capabilities);
282
+ return {
283
+ ...(window !== undefined ? { maxInputTokens: window } : {}),
284
+ ...(outputTokens !== undefined ? { maxOutputTokens: outputTokens } : {}),
285
+ ...(capabilities.tools === true ? { supportsToolCalls: true } : {}),
286
+ ...(capabilities.streaming === true ? { supportsStreaming: true } : {}),
287
+ ...(capabilities.reasoning === true ? { supportsReasoning: true } : {}),
288
+ ...(capabilities.vision === true ? { supportsVision: true } : {}),
289
+ };
290
+ }
291
+ const THINKING_LEVELS = ["low", "medium", "high", "xhigh"];
292
+ /**
293
+ * The language models (`type: "llm"`) of LM Studio's `GET /api/v1/models`, as BookWriter reads them: the thinking levels each declares
294
+ * (`capabilities.reasoning.allowed_options`, of which only low, medium, high and xhigh are levels), its default, the context it supports and the one
295
+ * it loaded. At most `LMSTUDIO_MAX_MODELS` entries are read. A payload that is not a list of models is an `AiCatalogError`.
296
+ */
297
+ export function parseLmStudioModels(payload) {
298
+ let models;
299
+ try {
300
+ const list = isRecord(payload) ? payload.models : undefined;
301
+ if (!Array.isArray(list))
302
+ throw invalid();
303
+ models = list;
304
+ }
305
+ catch {
306
+ throw invalid();
307
+ }
308
+ const result = [];
309
+ for (let index = 0; index < Math.min(models.length, LMSTUDIO_MAX_MODELS); index += 1) {
310
+ const model = guarded(() => {
311
+ const raw = models[index];
312
+ if (!isRecord(raw) || raw.type !== "llm" || typeof raw.key !== "string")
313
+ return undefined;
314
+ const key = raw.key.trim();
315
+ if (!validId(key, LMSTUDIO_MAX_KEY_LENGTH))
316
+ return undefined;
317
+ const maxContext = tokenCount(raw.max_context_length);
318
+ const instances = Array.isArray(raw.loaded_instances) ? raw.loaded_instances : [];
319
+ const loaded = [];
320
+ for (let at = 0; at < Math.min(instances.length, MAX_WALKED) && loaded.length < MAX_LOADED_INSTANCES; at += 1) {
321
+ const instance = instances[at];
322
+ if (!isRecord(instance) || !validId(instance.id, LMSTUDIO_MAX_KEY_LENGTH))
323
+ continue;
324
+ const contextLength = tokenCount(isRecord(instance.config) ? instance.config.context_length : undefined);
325
+ loaded.push({ id: instance.id, ...(contextLength !== undefined ? { contextLength } : {}) });
326
+ }
327
+ let reasoning;
328
+ // No block of capabilities is a server that said nothing: the levels stay unknown.
329
+ if (isRecord(raw.capabilities)) {
330
+ const declared = isRecord(raw.capabilities.reasoning) ? raw.capabilities.reasoning : undefined;
331
+ const allowed = declared && Array.isArray(declared.allowed_options) ? declared.allowed_options : [];
332
+ const options = THINKING_LEVELS.filter((level) => allowed.includes(level));
333
+ const preferred = declared?.default;
334
+ reasoning = options.length
335
+ ? { options: [...options], ...(typeof preferred === "string" && options.includes(preferred) ? { default: preferred } : {}) }
336
+ : null;
337
+ }
338
+ return {
339
+ key,
340
+ ...(reasoning !== undefined ? { reasoning } : {}),
341
+ ...(maxContext !== undefined ? { maxContext } : {}),
342
+ loaded,
343
+ };
344
+ });
345
+ if (model)
346
+ result.push(model);
347
+ }
348
+ return result;
349
+ }
350
+ /**
351
+ * The context of one LM Studio model, found as BookWriter finds it: by its key or by the id of one of its loaded instances; `loaded` is the context
352
+ * of that instance (else of the first one) and `max` the longest the model supports. `undefined` for a model the list does not have.
353
+ */
354
+ export function lmStudioContext(models, modelId) {
355
+ for (const model of models) {
356
+ const instance = model.loaded.find((entry) => entry.id === modelId);
357
+ if (model.key !== modelId && !instance)
358
+ continue;
359
+ const chosen = instance ?? model.loaded[0];
360
+ return {
361
+ ...(chosen?.contextLength !== undefined ? { loaded: chosen.contextLength } : {}),
362
+ ...(model.maxContext !== undefined ? { max: model.maxContext } : {}),
363
+ };
364
+ }
365
+ return undefined;
366
+ }
367
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/ai/catalog.ts"],"names":[],"mappings":"AAEA,2JAA2J;AAC3J,uJAAuJ;AACvJ,6JAA6J;AAC7J,gHAAgH;AAEhH,+HAA+H;AAC/H,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACxC,iCAAiC;AACjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,6HAA6H;AAC7H,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB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