@owlmeans/llm-common 0.1.18-rc.39 → 0.1.18-rc.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ extends these; `@owlmeans/llm` implements against them.
20
20
  ## Installation
21
21
 
22
22
  ```bash
23
- bun add @owlmeans/llm-common@^0.1.18-rc.39
23
+ bun add @owlmeans/llm-common@^0.1.18-rc.40
24
24
  ```
25
25
 
26
26
  ## Usage
@@ -96,7 +96,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
96
96
  your project's skill store (`.agents/skills/`):
97
97
 
98
98
  ```sh
99
- npx @owlmeans/agent-skills@^0.1.18-rc.49
99
+ npx @owlmeans/agent-skills@^0.1.18-rc.57
100
100
  ```
101
101
 
102
102
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
- "schemaVersion": 2,
2
+ "schemaVersion": 3,
3
3
  "package": "@owlmeans/llm-common",
4
- "version": "0.1.18-rc.39",
5
- "generatedAt": "2026-10-05T21:03:06.400Z",
4
+ "version": "0.1.18-rc.40",
5
+ "generatedAt": "2026-10-20T23:19:58.632Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: llm-common
3
- description: How to use @owlmeans/llm-common — runtime-free serializable contracts for LLM inference and execution (ModelProvider, ExecutionEffort/Level, ModelPolicy, PromptPolicy, SkillDefinition, ExecutionState and its cumulative-results view, PromptBlock, spectator records, NullCapture, LlmFileProvider). Auto-invoked when importing those contracts or extending them for a domain.
3
+ description: How to use @owlmeans/llm-common — runtime-free serializable contracts for LLM inference and execution (ModelProvider, ExecutionEffort/Level, ModelPolicy, PromptPolicy, SkillDefinition, ExecutionState and its cumulative-results view, PromptBlock/PromptRegion, PromptFocus, PackagePurpose, CacheTtlPolicy, spectator records, NullCapture, LlmFileProvider). Auto-invoked when importing those contracts or extending them for a domain.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/llm-common
9
9
 
10
10
  **Layer:** Core
11
- **Install:** `"@owlmeans/llm-common": "^0.1.18-rc.39"` in `dependencies`
11
+ **Install:** `"@owlmeans/llm-common": "^0.1.18-rc.40"` in `dependencies`
12
12
 
13
13
  The contracts half of the LLM stack. **No `@langchain/*` runtime dependency** — importable
14
14
  from a browser bundle, a queue worker, or any package that must not pull an inference SDK.
@@ -31,15 +31,18 @@ The dependency direction is one-way: a domain contracts package extends these;
31
31
  | `UTILITY_ROLE` | `'utility'` — the conventional cheap tier for side calls (a relevance pick, a classification). `ModelPolicy.utilityRole` points it at another alias; `ExecutionService.utility` resolves it. |
32
32
  | `ExecutionState` / `TaskExecutionState` | The persistable core (`level`/`purpose`/`policy`, optional `prompt`/`inquiry`/`results`, plus `phase`/`completed`/`cursor`/`data`). |
33
33
  | `LlmPurpose` | `{ type?, dedication? }` — metadata carried on every model call. |
34
- | `PromptBlock`, `PROMPT_BLOCK_ORDER`, `DEFAULT_SKILL_ORDER` | The ordered sections of a composed system prompt — `Role`, `Skills`, `Packages`, `Results`, `Context`; the order IS the cache key. |
34
+ | `PromptBlock`, `PROMPT_BLOCK_ORDER`, `DEFAULT_SKILL_ORDER` | The ordered sections of a composed prompt — `Role`, `Skills`, `Packages`, `Results`, `Context`, `Tail`; the order IS the cache key. |
35
+ | `PromptRegion`, `PROMPT_REGIONS` | Where each block travels: `System` (role, skills, packages — the system message), `Project` (results, context — a user turn right after it), `Tail` (appended to the final message, never cached). |
36
+ | `PackagePurpose`, `PACKAGE_PURPOSES` | The closed vocabulary a package skill's parts are tagged with and a focus selects by (`view`, `form`, … `ops`); `library-manager` keeps a pinned copy. |
37
+ | `PromptFocus` | `{ packages?, purposes?, parts?, types?, late? }` — the package documentation (and types) a persona works with, chosen once per persona and story; arrays merge as a first-seen union down the chain, the deepest `late` wins. |
35
38
  | `CumulativeResults`, `CumulativeResultsSection` | A pipeline step's view of what earlier steps produced: `step`, rendered `sections` (oldest first), `omitted` step names, `chars`, and a `digest` that is never rendered. |
36
39
  | `renderCumulativeResults(view)` · `CUMULATIVE_RESULTS_PREAMBLE` · `CUMULATIVE_RESULTS_OMITTED_LEAD`/`_TAIL` | The view as prompt text: the fixed rules, the sections, the "not listed for space" line — or `''` for no view. |
37
40
  | `SkillDefinition` | One named block of reusable prompt knowledge. `body` must be a pure constant. |
38
- | `PromptPolicy` | `{ role?, skills?, cacheSystem?, cacheTtl? }` — carried on `ExecutionState`, merged downward. |
39
- | `CacheTtl`, `CacheUsage` | `'5m' \| '1h'`; normalized prompt-cache accounting. |
41
+ | `PromptPolicy` | `{ role?, skills?, cacheSystem?, cacheTtl?, focus? }` — carried on `ExecutionState`, merged downward. `cacheSystem: false` leaves the system and project message unmarked. |
42
+ | `CacheTtl`, `CacheTtlPolicy`, `CacheUsage` | `'5m' \| '1h'`; a lifetime per breakpoint (`skills`, `packages`, `project`, `stable`), which never rises along the prefix; normalized prompt-cache accounting — `creationLong` is the 1-hour share of `creation`, present only when non-zero. |
40
43
  | `LlmFileProvider`, `FileProviderRef`, `resolveFileProvider` | The file contract prompt plugins work against — four members, every path relative to the host's project root. `FileProviderRef` accepts the provider or a thunk returning one; `resolveFileProvider` unwraps whichever form arrived, or `undefined`. |
41
- | `NullCapture`, `NullKind` | Full diagnostics of a call that returned nothing usable. |
42
- | `SpectatorArgument`, `SpectatorEntry`, `SpectatorEntryLogged`, `SpectatorEntryMessage` | What an observability sink stores. |
44
+ | `NullCapture`, `NullKind` | Full diagnostics of a call that returned nothing usable; `request.useCache` = the prepared request carried a breakpoint, `request.stable` = the caller's `stable` count. |
45
+ | `SpectatorArgument`, `SpectatorEntry`, `SpectatorEntryLogged`, `SpectatorEntryMessage` | What an observability sink stores. `SpectatorArgument.model` is the model that ANSWERED (a fallback rung's own id); absent, a sink falls back to its own resolution. |
43
46
 
44
47
  ## `LlmFileProvider` — what a host must supply
45
48
 
@@ -119,10 +122,10 @@ on a spectator message only.
119
122
  ## Testing
120
123
 
121
124
  Category A. `bun test ./tests` (the package's `test` script, so the root run includes it):
122
- `inquiry.spec.ts` for the answer helpers, `results.spec.ts` for the block order and the rendered view.
125
+ `inquiry.spec.ts` for the answer helpers, `results.spec.ts` for the block order, the regions, the purpose list and the rendered view.
123
126
 
124
127
  ## Related
125
128
 
126
129
  - [[llm]] — the runtime that implements these contracts
127
- - [[llm-prompt-caching]] — why `Results` sits where it does in the block order
130
+ - [[llm-prompt-caching]] — the regions, the cache boundaries and their lifetimes
128
131
  - [[agent]] — `cumulativeResultsPlugin`, which cuts the view
package/build/consts.d.ts CHANGED
@@ -85,7 +85,7 @@ export declare enum SpectatorContentType {
85
85
  /** Default spectator entry kind for consumers that do not classify their calls. */
86
86
  export declare const SPECTATOR_GENERAL = "general";
87
87
  /**
88
- * Ordered sections of a composed system prompt.
88
+ * Ordered sections of a composed prompt.
89
89
  *
90
90
  * The ordering is not cosmetic — it IS the prompt-cache design. Every provider caches
91
91
  * a prompt by exact PREFIX match, so the sections are laid out most-stable first and a
@@ -94,22 +94,27 @@ export declare const SPECTATOR_GENERAL = "general";
94
94
  * - `Role` — the base system prompt defining who the model is. Stable per role.
95
95
  * - `Skills` — the statically declared capabilities, rendered in a deterministic
96
96
  * order. Stable per helper. A breakpoint closes `Role` + `Skills`.
97
- * - `Packages` — capabilities resolved from whatever the request happens to mention.
98
- * Varies per request, so it gets its OWN breakpoint and can never
99
- * invalidate the two blocks above it.
97
+ * - `Packages` — the package documentation this persona needs for the work at hand (a focus),
98
+ * or what the request happens to mention. It gets its OWN breakpoint and can
99
+ * never invalidate the two blocks above it.
100
100
  * - `Results` — what the earlier steps of the pipeline this call runs in produced
101
101
  * (`ExecutionState.results`). Stable within one step, different on the
102
102
  * next, so it sits BELOW every boundary that is cached across steps and
103
- * is emitted only when a view is present — a call without one composes
104
- * exactly the bytes it composed before this block existed.
105
- * - `Context` — volatile, caller-supplied system text. Never cached.
103
+ * is emitted only when a view is present.
104
+ * - `Context` — caller-supplied system text and project facts. Stable for one step of the work,
105
+ * so it sits in the project message with `Results`.
106
+ * - `Tail` — what belongs to ONE call: per-call skills, late packages and types. Appended to the
107
+ * final message after the call's payload and never cached.
108
+ *
109
+ * Where each block is sent is {@link PROMPT_REGIONS}.
106
110
  */
107
111
  export declare enum PromptBlock {
108
112
  Role = "role",
109
113
  Skills = "skills",
110
114
  Packages = "packages",
111
115
  Results = "results",
112
- Context = "context"
116
+ Context = "context",
117
+ Tail = "tail"
113
118
  }
114
119
  /**
115
120
  * Emission order of {@link PromptBlock}. Declared explicitly rather than derived from
@@ -117,6 +122,57 @@ export declare enum PromptBlock {
117
122
  * and enum iteration order is not part of any contract worth betting a cache on.
118
123
  */
119
124
  export declare const PROMPT_BLOCK_ORDER: readonly PromptBlock[];
125
+ /**
126
+ * Where a composed block travels in a request. Each region is stable for a different span of
127
+ * work, so each closes on its own cache breakpoint (the tail on none):
128
+ *
129
+ * - `System` — the system message: who the model is and what it may use. Stable per persona
130
+ * (role + skills) and per persona and story (packages).
131
+ * - `Project` — the user turn right after the system: facts about this project and step.
132
+ * - `Tail` — appended to the final message, after the call's own payload.
133
+ */
134
+ export declare enum PromptRegion {
135
+ System = "system",
136
+ Project = "project",
137
+ Tail = "tail"
138
+ }
139
+ /** The blocks of each {@link PromptRegion}, in emission order. */
140
+ export declare const PROMPT_REGIONS: Readonly<Record<PromptRegion, readonly PromptBlock[]>>;
141
+ /**
142
+ * What a part of a package's documentation is FOR — the closed vocabulary a chunked package skill
143
+ * tags its parts with, and a {@link PromptFocus} selects them by. `library-manager` keeps a copy
144
+ * (it cannot import this package) and a test pins that the two are equal.
145
+ */
146
+ export declare enum PackagePurpose {
147
+ View = "view",
148
+ Form = "form",
149
+ List = "list",
150
+ Detail = "detail",
151
+ Dialog = "dialog",
152
+ Picker = "picker",
153
+ Navigation = "navigation",
154
+ Layout = "layout",
155
+ Screen = "screen",
156
+ Theme = "theme",
157
+ Feedback = "feedback",
158
+ State = "state",
159
+ ClientApi = "client-api",
160
+ ServerApi = "server-api",
161
+ Data = "data",
162
+ Migration = "migration",
163
+ Query = "query",
164
+ Auth = "auth",
165
+ Consent = "consent",
166
+ Payment = "payment",
167
+ Planning = "planning",
168
+ Job = "job",
169
+ Agent = "agent",
170
+ Config = "config",
171
+ Test = "test",
172
+ Ops = "ops"
173
+ }
174
+ /** Every {@link PackagePurpose}, in declaration order — declared, not derived from the enum. */
175
+ export declare const PACKAGE_PURPOSES: readonly PackagePurpose[];
120
176
  /** Sort weight of a skill that declares none — see `SkillDefinition.order`. */
121
177
  export declare const DEFAULT_SKILL_ORDER = 100;
122
178
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,oBAAY,aAAa;IACvB,yFAAyF;IACzF,MAAM,WAAW;IACjB,8BAA8B;IAC9B,SAAS,cAAc;IACvB,yFAAyF;IACzF,UAAU,eAAe;IACzB;;;;;;;;;;;;OAYG;IACH,SAAS,cAAc;CACxB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED;;;;GAIG;AACH,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ;AAED;;;;;GAKG;AACH,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;CACZ;AAED,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,EAAE,SAAS,WAAW,EAGpD,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,cAAc;IACxB,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+E;AAC/E,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,YAAY,CAAA"}
package/build/consts.js CHANGED
@@ -94,7 +94,7 @@ export var SpectatorContentType;
94
94
  /** Default spectator entry kind for consumers that do not classify their calls. */
95
95
  export const SPECTATOR_GENERAL = 'general';
96
96
  /**
97
- * Ordered sections of a composed system prompt.
97
+ * Ordered sections of a composed prompt.
98
98
  *
99
99
  * The ordering is not cosmetic — it IS the prompt-cache design. Every provider caches
100
100
  * a prompt by exact PREFIX match, so the sections are laid out most-stable first and a
@@ -103,15 +103,19 @@ export const SPECTATOR_GENERAL = 'general';
103
103
  * - `Role` — the base system prompt defining who the model is. Stable per role.
104
104
  * - `Skills` — the statically declared capabilities, rendered in a deterministic
105
105
  * order. Stable per helper. A breakpoint closes `Role` + `Skills`.
106
- * - `Packages` — capabilities resolved from whatever the request happens to mention.
107
- * Varies per request, so it gets its OWN breakpoint and can never
108
- * invalidate the two blocks above it.
106
+ * - `Packages` — the package documentation this persona needs for the work at hand (a focus),
107
+ * or what the request happens to mention. It gets its OWN breakpoint and can
108
+ * never invalidate the two blocks above it.
109
109
  * - `Results` — what the earlier steps of the pipeline this call runs in produced
110
110
  * (`ExecutionState.results`). Stable within one step, different on the
111
111
  * next, so it sits BELOW every boundary that is cached across steps and
112
- * is emitted only when a view is present — a call without one composes
113
- * exactly the bytes it composed before this block existed.
114
- * - `Context` — volatile, caller-supplied system text. Never cached.
112
+ * is emitted only when a view is present.
113
+ * - `Context` — caller-supplied system text and project facts. Stable for one step of the work,
114
+ * so it sits in the project message with `Results`.
115
+ * - `Tail` — what belongs to ONE call: per-call skills, late packages and types. Appended to the
116
+ * final message after the call's payload and never cached.
117
+ *
118
+ * Where each block is sent is {@link PROMPT_REGIONS}.
115
119
  */
116
120
  export var PromptBlock;
117
121
  (function (PromptBlock) {
@@ -120,6 +124,7 @@ export var PromptBlock;
120
124
  PromptBlock["Packages"] = "packages";
121
125
  PromptBlock["Results"] = "results";
122
126
  PromptBlock["Context"] = "context";
127
+ PromptBlock["Tail"] = "tail";
123
128
  })(PromptBlock || (PromptBlock = {}));
124
129
  /**
125
130
  * Emission order of {@link PromptBlock}. Declared explicitly rather than derived from
@@ -132,7 +137,73 @@ export const PROMPT_BLOCK_ORDER = [
132
137
  PromptBlock.Packages,
133
138
  PromptBlock.Results,
134
139
  PromptBlock.Context,
140
+ PromptBlock.Tail,
135
141
  ];
142
+ /**
143
+ * Where a composed block travels in a request. Each region is stable for a different span of
144
+ * work, so each closes on its own cache breakpoint (the tail on none):
145
+ *
146
+ * - `System` — the system message: who the model is and what it may use. Stable per persona
147
+ * (role + skills) and per persona and story (packages).
148
+ * - `Project` — the user turn right after the system: facts about this project and step.
149
+ * - `Tail` — appended to the final message, after the call's own payload.
150
+ */
151
+ export var PromptRegion;
152
+ (function (PromptRegion) {
153
+ PromptRegion["System"] = "system";
154
+ PromptRegion["Project"] = "project";
155
+ PromptRegion["Tail"] = "tail";
156
+ })(PromptRegion || (PromptRegion = {}));
157
+ /** The blocks of each {@link PromptRegion}, in emission order. */
158
+ export const PROMPT_REGIONS = Object.freeze({
159
+ [PromptRegion.System]: [PromptBlock.Role, PromptBlock.Skills, PromptBlock.Packages],
160
+ [PromptRegion.Project]: [PromptBlock.Results, PromptBlock.Context],
161
+ [PromptRegion.Tail]: [PromptBlock.Tail],
162
+ });
163
+ /**
164
+ * What a part of a package's documentation is FOR — the closed vocabulary a chunked package skill
165
+ * tags its parts with, and a {@link PromptFocus} selects them by. `library-manager` keeps a copy
166
+ * (it cannot import this package) and a test pins that the two are equal.
167
+ */
168
+ export var PackagePurpose;
169
+ (function (PackagePurpose) {
170
+ PackagePurpose["View"] = "view";
171
+ PackagePurpose["Form"] = "form";
172
+ PackagePurpose["List"] = "list";
173
+ PackagePurpose["Detail"] = "detail";
174
+ PackagePurpose["Dialog"] = "dialog";
175
+ PackagePurpose["Picker"] = "picker";
176
+ PackagePurpose["Navigation"] = "navigation";
177
+ PackagePurpose["Layout"] = "layout";
178
+ PackagePurpose["Screen"] = "screen";
179
+ PackagePurpose["Theme"] = "theme";
180
+ PackagePurpose["Feedback"] = "feedback";
181
+ PackagePurpose["State"] = "state";
182
+ PackagePurpose["ClientApi"] = "client-api";
183
+ PackagePurpose["ServerApi"] = "server-api";
184
+ PackagePurpose["Data"] = "data";
185
+ PackagePurpose["Migration"] = "migration";
186
+ PackagePurpose["Query"] = "query";
187
+ PackagePurpose["Auth"] = "auth";
188
+ PackagePurpose["Consent"] = "consent";
189
+ PackagePurpose["Payment"] = "payment";
190
+ PackagePurpose["Planning"] = "planning";
191
+ PackagePurpose["Job"] = "job";
192
+ PackagePurpose["Agent"] = "agent";
193
+ PackagePurpose["Config"] = "config";
194
+ PackagePurpose["Test"] = "test";
195
+ PackagePurpose["Ops"] = "ops";
196
+ })(PackagePurpose || (PackagePurpose = {}));
197
+ /** Every {@link PackagePurpose}, in declaration order — declared, not derived from the enum. */
198
+ export const PACKAGE_PURPOSES = Object.freeze([
199
+ PackagePurpose.View, PackagePurpose.Form, PackagePurpose.List, PackagePurpose.Detail,
200
+ PackagePurpose.Dialog, PackagePurpose.Picker, PackagePurpose.Navigation, PackagePurpose.Layout,
201
+ PackagePurpose.Screen, PackagePurpose.Theme, PackagePurpose.Feedback, PackagePurpose.State,
202
+ PackagePurpose.ClientApi, PackagePurpose.ServerApi, PackagePurpose.Data, PackagePurpose.Migration,
203
+ PackagePurpose.Query, PackagePurpose.Auth, PackagePurpose.Consent, PackagePurpose.Payment,
204
+ PackagePurpose.Planning, PackagePurpose.Job, PackagePurpose.Agent, PackagePurpose.Config,
205
+ PackagePurpose.Test, PackagePurpose.Ops,
206
+ ]);
136
207
  /** Sort weight of a skill that declares none — see `SkillDefinition.order`. */
137
208
  export const DEFAULT_SKILL_ORDER = 100;
138
209
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA;;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AA;IACb,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,uCAAqB,CAAA;IACrB,6BAAW,CAAA;IACX,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,+BAAa,CAAA;IACb,6BAAW,CAAA;AACb,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACvE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,MAAM;IACpF,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,MAAM;IAC9F,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,KAAK;IAC1F,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS;IACjG,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO;IACzF,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM;IACxF,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,GAAG;CACxC,CAAC,CAAA;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA"}
@@ -8,6 +8,12 @@ export interface SpectatorArgument {
8
8
  tries?: number;
9
9
  messages: SpectatorEntryMessage[];
10
10
  startedAt?: number;
11
+ /**
12
+ * The model that ANSWERED — the active rung's own model id, which differs from the role's
13
+ * primary once a fallback took over. Absent when the caller could not tell; a sink then falls
14
+ * back to its own resolution.
15
+ */
16
+ model?: string;
11
17
  }
12
18
  /** A stored spectator record — the argument plus the resolved call context. */
13
19
  export interface SpectatorEntry extends SpectatorArgument {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/spectator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,qBAAqB,EAAE,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,EAAE,EAAE,MAAM,CAAA;CACX;AAED,mEAAmE;AACnE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,oBAAoB,CAAA;IACjC,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/spectator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,qBAAqB,EAAE,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,EAAE,EAAE,MAAM,CAAA;CACX;AAED,mEAAmE;AACnE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,oBAAoB,CAAA;IACjC,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb"}
package/build/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ExecutionEffort, ExecutionLevel, ModelEffort, PromptBlock } from './consts.js';
1
+ import type { ExecutionEffort, ExecutionLevel, ModelEffort, PackagePurpose, PromptBlock } from './consts.js';
2
2
  import type { InquiryConfig } from './inquiry/types.js';
3
3
  import type { CumulativeResults } from './results/types.js';
4
4
  /**
@@ -67,6 +67,46 @@ export interface ModelPolicy {
67
67
  * prefix that survives a long run, not for a one-shot call.
68
68
  */
69
69
  export type CacheTtl = '5m' | '1h';
70
+ /**
71
+ * A cache lifetime per breakpoint of the prompt layout, earliest first. An omitted key keeps the
72
+ * level below it (the service default, then `'5m'`). Whatever is asked, the lifetimes never RISE
73
+ * along the prefix — a provider refuses a longer-lived entry after a shorter-lived one — so a
74
+ * `'1h'` behind a `'5m'` is clamped to `'5m'`.
75
+ */
76
+ export interface CacheTtlPolicy {
77
+ /** The role + skills breakpoint — stable for a persona. */
78
+ skills?: CacheTtl;
79
+ /** The packages breakpoint — stable for a persona working on one story. */
80
+ packages?: CacheTtl;
81
+ /** The project message's breakpoint — stable for one step of the work. */
82
+ project?: CacheTtl;
83
+ /** The breakpoint after the caller's `stable` lead messages — stable for one batch of calls. */
84
+ stable?: CacheTtl;
85
+ }
86
+ /**
87
+ * Which package documentation a persona works with, chosen ONCE per persona and story rather than
88
+ * detected from each message — so the packages block stays byte-identical for every call of that
89
+ * work. Present, it switches the package plugin from detection to selection; absent, packages are
90
+ * detected from the messages as before.
91
+ *
92
+ * Arrays merge down the execution chain as a first-seen union; the plugin sorts what it renders.
93
+ */
94
+ export interface PromptFocus {
95
+ /** The `@owlmeans/*` packages whose documentation belongs in the cached packages block. */
96
+ packages?: string[];
97
+ /** Which parts of those packages to load, by what they are for. */
98
+ purposes?: PackagePurpose[];
99
+ /** Parts named outright, as `<package>#<part>` (`@owlmeans/web-panel#picker`). */
100
+ parts?: string[];
101
+ /** Domain types whose definitions belong in the project message. */
102
+ types?: string[];
103
+ /**
104
+ * Whether a package a call's messages IMPORT but the focus lacks is still loaded, into the
105
+ * uncached tail (cores only, capped). Defaults to `true`; `false` keeps the prompt to the focus.
106
+ * The deepest level that sets it wins.
107
+ */
108
+ late?: boolean;
109
+ }
70
110
  /**
71
111
  * One named, reusable chunk of system-prompt knowledge — a capability the model is told
72
112
  * it has. Registered once (by the package that owns the knowledge or by the final app)
@@ -104,10 +144,15 @@ export interface PromptPolicy {
104
144
  role?: string;
105
145
  /** Skill aliases enabled at this level. */
106
146
  skills?: string[];
107
- /** Mark the composed system prompt cacheable. Defaults to `true`. */
147
+ /** Mark the composed prompt cacheable (system and project message). Defaults to `true`. */
108
148
  cacheSystem?: boolean;
109
- /** Cache lifetime for the system prefix. Defaults to `'5m'`. */
110
- cacheTtl?: CacheTtl;
149
+ /**
150
+ * Cache lifetimes: one for every breakpoint, or one per breakpoint. Defaults to `'5m'`
151
+ * everywhere; `'1h'` is opt-in and never rises along the prefix (see {@link CacheTtlPolicy}).
152
+ */
153
+ cacheTtl?: CacheTtl | CacheTtlPolicy;
154
+ /** Which package documentation and types this work uses — see {@link PromptFocus}. */
155
+ focus?: PromptFocus;
111
156
  }
112
157
  /**
113
158
  * Prompt-cache accounting for a single call, normalized across providers. The only
@@ -117,8 +162,13 @@ export interface PromptPolicy {
117
162
  export interface CacheUsage {
118
163
  /** Tokens served from cache (~0.1x price). */
119
164
  read: number;
120
- /** Tokens written to cache (~1.25x price at 5m TTL, ~2x at 1h). */
165
+ /** Tokens written to cache (~1.25x price at 5m TTL, ~2x at 1h) — both lifetimes together. */
121
166
  creation: number;
167
+ /**
168
+ * Of {@link creation}, the tokens written at the 1-hour TTL. Present only when the provider
169
+ * reported a non-zero 1-hour write.
170
+ */
171
+ creationLong?: number;
122
172
  /** Tokens processed at full price. */
123
173
  input: number;
124
174
  output: number;
@@ -199,7 +249,10 @@ export interface NullCapture {
199
249
  toolName: string;
200
250
  innerSchema: unknown;
201
251
  };
252
+ /** Whether the prepared request carried at least one cache breakpoint. */
202
253
  useCache: boolean;
254
+ /** How many lead messages the caller declared stable across calls (`LlmCallOptions.stable`). */
255
+ stable?: number;
203
256
  };
204
257
  response: {
205
258
  content: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE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AAA;KAChB,CAAA;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO,CAAA;QAChB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,GAAG,IAAI,CAAA;IACR,WAAW,EAAE;QACX,+FAA+F;QAC/F,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,YAAY,EAAE,OAAO,CAAA;QACrB;;;;WAIG;QACH,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,WAAW,EAAE,OAAO,CAAA;KACrB,CAAA;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/llm-common",
3
- "version": "0.1.18-rc.39",
3
+ "version": "0.1.18-rc.40",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/consts.ts CHANGED
@@ -97,7 +97,7 @@ export enum SpectatorContentType {
97
97
  export const SPECTATOR_GENERAL = 'general'
98
98
 
99
99
  /**
100
- * Ordered sections of a composed system prompt.
100
+ * Ordered sections of a composed prompt.
101
101
  *
102
102
  * The ordering is not cosmetic — it IS the prompt-cache design. Every provider caches
103
103
  * a prompt by exact PREFIX match, so the sections are laid out most-stable first and a
@@ -106,15 +106,19 @@ export const SPECTATOR_GENERAL = 'general'
106
106
  * - `Role` — the base system prompt defining who the model is. Stable per role.
107
107
  * - `Skills` — the statically declared capabilities, rendered in a deterministic
108
108
  * order. Stable per helper. A breakpoint closes `Role` + `Skills`.
109
- * - `Packages` — capabilities resolved from whatever the request happens to mention.
110
- * Varies per request, so it gets its OWN breakpoint and can never
111
- * invalidate the two blocks above it.
109
+ * - `Packages` — the package documentation this persona needs for the work at hand (a focus),
110
+ * or what the request happens to mention. It gets its OWN breakpoint and can
111
+ * never invalidate the two blocks above it.
112
112
  * - `Results` — what the earlier steps of the pipeline this call runs in produced
113
113
  * (`ExecutionState.results`). Stable within one step, different on the
114
114
  * next, so it sits BELOW every boundary that is cached across steps and
115
- * is emitted only when a view is present — a call without one composes
116
- * exactly the bytes it composed before this block existed.
117
- * - `Context` — volatile, caller-supplied system text. Never cached.
115
+ * is emitted only when a view is present.
116
+ * - `Context` — caller-supplied system text and project facts. Stable for one step of the work,
117
+ * so it sits in the project message with `Results`.
118
+ * - `Tail` — what belongs to ONE call: per-call skills, late packages and types. Appended to the
119
+ * final message after the call's payload and never cached.
120
+ *
121
+ * Where each block is sent is {@link PROMPT_REGIONS}.
118
122
  */
119
123
  export enum PromptBlock {
120
124
  Role = 'role',
@@ -122,6 +126,7 @@ export enum PromptBlock {
122
126
  Packages = 'packages',
123
127
  Results = 'results',
124
128
  Context = 'context',
129
+ Tail = 'tail',
125
130
  }
126
131
 
127
132
  /**
@@ -135,8 +140,76 @@ export const PROMPT_BLOCK_ORDER: readonly PromptBlock[] = [
135
140
  PromptBlock.Packages,
136
141
  PromptBlock.Results,
137
142
  PromptBlock.Context,
143
+ PromptBlock.Tail,
138
144
  ] as const
139
145
 
146
+ /**
147
+ * Where a composed block travels in a request. Each region is stable for a different span of
148
+ * work, so each closes on its own cache breakpoint (the tail on none):
149
+ *
150
+ * - `System` — the system message: who the model is and what it may use. Stable per persona
151
+ * (role + skills) and per persona and story (packages).
152
+ * - `Project` — the user turn right after the system: facts about this project and step.
153
+ * - `Tail` — appended to the final message, after the call's own payload.
154
+ */
155
+ export enum PromptRegion {
156
+ System = 'system',
157
+ Project = 'project',
158
+ Tail = 'tail',
159
+ }
160
+
161
+ /** The blocks of each {@link PromptRegion}, in emission order. */
162
+ export const PROMPT_REGIONS: Readonly<Record<PromptRegion, readonly PromptBlock[]>> = Object.freeze({
163
+ [PromptRegion.System]: [PromptBlock.Role, PromptBlock.Skills, PromptBlock.Packages],
164
+ [PromptRegion.Project]: [PromptBlock.Results, PromptBlock.Context],
165
+ [PromptRegion.Tail]: [PromptBlock.Tail],
166
+ })
167
+
168
+ /**
169
+ * What a part of a package's documentation is FOR — the closed vocabulary a chunked package skill
170
+ * tags its parts with, and a {@link PromptFocus} selects them by. `library-manager` keeps a copy
171
+ * (it cannot import this package) and a test pins that the two are equal.
172
+ */
173
+ export enum PackagePurpose {
174
+ View = 'view',
175
+ Form = 'form',
176
+ List = 'list',
177
+ Detail = 'detail',
178
+ Dialog = 'dialog',
179
+ Picker = 'picker',
180
+ Navigation = 'navigation',
181
+ Layout = 'layout',
182
+ Screen = 'screen',
183
+ Theme = 'theme',
184
+ Feedback = 'feedback',
185
+ State = 'state',
186
+ ClientApi = 'client-api',
187
+ ServerApi = 'server-api',
188
+ Data = 'data',
189
+ Migration = 'migration',
190
+ Query = 'query',
191
+ Auth = 'auth',
192
+ Consent = 'consent',
193
+ Payment = 'payment',
194
+ Planning = 'planning',
195
+ Job = 'job',
196
+ Agent = 'agent',
197
+ Config = 'config',
198
+ Test = 'test',
199
+ Ops = 'ops',
200
+ }
201
+
202
+ /** Every {@link PackagePurpose}, in declaration order — declared, not derived from the enum. */
203
+ export const PACKAGE_PURPOSES: readonly PackagePurpose[] = Object.freeze([
204
+ PackagePurpose.View, PackagePurpose.Form, PackagePurpose.List, PackagePurpose.Detail,
205
+ PackagePurpose.Dialog, PackagePurpose.Picker, PackagePurpose.Navigation, PackagePurpose.Layout,
206
+ PackagePurpose.Screen, PackagePurpose.Theme, PackagePurpose.Feedback, PackagePurpose.State,
207
+ PackagePurpose.ClientApi, PackagePurpose.ServerApi, PackagePurpose.Data, PackagePurpose.Migration,
208
+ PackagePurpose.Query, PackagePurpose.Auth, PackagePurpose.Consent, PackagePurpose.Payment,
209
+ PackagePurpose.Planning, PackagePurpose.Job, PackagePurpose.Agent, PackagePurpose.Config,
210
+ PackagePurpose.Test, PackagePurpose.Ops,
211
+ ])
212
+
140
213
  /** Sort weight of a skill that declares none — see `SkillDefinition.order`. */
141
214
  export const DEFAULT_SKILL_ORDER = 100
142
215
 
@@ -9,6 +9,12 @@ export interface SpectatorArgument {
9
9
  tries?: number
10
10
  messages: SpectatorEntryMessage[]
11
11
  startedAt?: number
12
+ /**
13
+ * The model that ANSWERED — the active rung's own model id, which differs from the role's
14
+ * primary once a fallback took over. Absent when the caller could not tell; a sink then falls
15
+ * back to its own resolution.
16
+ */
17
+ model?: string
12
18
  }
13
19
 
14
20
  /** A stored spectator record — the argument plus the resolved call context. */
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ExecutionEffort, ExecutionLevel, ModelEffort, PromptBlock } from './consts.js'
1
+ import type { ExecutionEffort, ExecutionLevel, ModelEffort, PackagePurpose, PromptBlock } from './consts.js'
2
2
  import type { InquiryConfig } from './inquiry/types.js'
3
3
  import type { CumulativeResults } from './results/types.js'
4
4
 
@@ -74,6 +74,48 @@ export interface ModelPolicy {
74
74
  */
75
75
  export type CacheTtl = '5m' | '1h'
76
76
 
77
+ /**
78
+ * A cache lifetime per breakpoint of the prompt layout, earliest first. An omitted key keeps the
79
+ * level below it (the service default, then `'5m'`). Whatever is asked, the lifetimes never RISE
80
+ * along the prefix — a provider refuses a longer-lived entry after a shorter-lived one — so a
81
+ * `'1h'` behind a `'5m'` is clamped to `'5m'`.
82
+ */
83
+ export interface CacheTtlPolicy {
84
+ /** The role + skills breakpoint — stable for a persona. */
85
+ skills?: CacheTtl
86
+ /** The packages breakpoint — stable for a persona working on one story. */
87
+ packages?: CacheTtl
88
+ /** The project message's breakpoint — stable for one step of the work. */
89
+ project?: CacheTtl
90
+ /** The breakpoint after the caller's `stable` lead messages — stable for one batch of calls. */
91
+ stable?: CacheTtl
92
+ }
93
+
94
+ /**
95
+ * Which package documentation a persona works with, chosen ONCE per persona and story rather than
96
+ * detected from each message — so the packages block stays byte-identical for every call of that
97
+ * work. Present, it switches the package plugin from detection to selection; absent, packages are
98
+ * detected from the messages as before.
99
+ *
100
+ * Arrays merge down the execution chain as a first-seen union; the plugin sorts what it renders.
101
+ */
102
+ export interface PromptFocus {
103
+ /** The `@owlmeans/*` packages whose documentation belongs in the cached packages block. */
104
+ packages?: string[]
105
+ /** Which parts of those packages to load, by what they are for. */
106
+ purposes?: PackagePurpose[]
107
+ /** Parts named outright, as `<package>#<part>` (`@owlmeans/web-panel#picker`). */
108
+ parts?: string[]
109
+ /** Domain types whose definitions belong in the project message. */
110
+ types?: string[]
111
+ /**
112
+ * Whether a package a call's messages IMPORT but the focus lacks is still loaded, into the
113
+ * uncached tail (cores only, capped). Defaults to `true`; `false` keeps the prompt to the focus.
114
+ * The deepest level that sets it wins.
115
+ */
116
+ late?: boolean
117
+ }
118
+
77
119
  /**
78
120
  * One named, reusable chunk of system-prompt knowledge — a capability the model is told
79
121
  * it has. Registered once (by the package that owns the knowledge or by the final app)
@@ -112,10 +154,15 @@ export interface PromptPolicy {
112
154
  role?: string
113
155
  /** Skill aliases enabled at this level. */
114
156
  skills?: string[]
115
- /** Mark the composed system prompt cacheable. Defaults to `true`. */
157
+ /** Mark the composed prompt cacheable (system and project message). Defaults to `true`. */
116
158
  cacheSystem?: boolean
117
- /** Cache lifetime for the system prefix. Defaults to `'5m'`. */
118
- cacheTtl?: CacheTtl
159
+ /**
160
+ * Cache lifetimes: one for every breakpoint, or one per breakpoint. Defaults to `'5m'`
161
+ * everywhere; `'1h'` is opt-in and never rises along the prefix (see {@link CacheTtlPolicy}).
162
+ */
163
+ cacheTtl?: CacheTtl | CacheTtlPolicy
164
+ /** Which package documentation and types this work uses — see {@link PromptFocus}. */
165
+ focus?: PromptFocus
119
166
  }
120
167
 
121
168
  /**
@@ -126,8 +173,13 @@ export interface PromptPolicy {
126
173
  export interface CacheUsage {
127
174
  /** Tokens served from cache (~0.1x price). */
128
175
  read: number
129
- /** Tokens written to cache (~1.25x price at 5m TTL, ~2x at 1h). */
176
+ /** Tokens written to cache (~1.25x price at 5m TTL, ~2x at 1h) — both lifetimes together. */
130
177
  creation: number
178
+ /**
179
+ * Of {@link creation}, the tokens written at the 1-hour TTL. Present only when the provider
180
+ * reported a non-zero 1-hour write.
181
+ */
182
+ creationLong?: number
131
183
  /** Tokens processed at full price. */
132
184
  input: number
133
185
  output: number
@@ -209,7 +261,10 @@ export interface NullCapture {
209
261
  request: {
210
262
  messages: unknown[]
211
263
  schema?: { toolName: string; innerSchema: unknown }
264
+ /** Whether the prepared request carried at least one cache breakpoint. */
212
265
  useCache: boolean
266
+ /** How many lead messages the caller declared stable across calls (`LlmCallOptions.stable`). */
267
+ stable?: number
213
268
  }
214
269
  response: {
215
270
  content: unknown
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from 'bun:test'
2
2
  import {
3
- CUMULATIVE_RESULTS_OMITTED_LEAD, CUMULATIVE_RESULTS_PREAMBLE, PROMPT_BLOCK_ORDER, PromptBlock,
4
- renderCumulativeResults,
3
+ CUMULATIVE_RESULTS_OMITTED_LEAD, CUMULATIVE_RESULTS_PREAMBLE, PACKAGE_PURPOSES, PackagePurpose,
4
+ PROMPT_BLOCK_ORDER, PROMPT_REGIONS, PromptBlock, PromptRegion, renderCumulativeResults,
5
5
  } from '../src/index.js'
6
6
  import type { CumulativeResults } from '../src/index.js'
7
7
 
@@ -24,12 +24,28 @@ const view = (patch: Partial<CumulativeResults> = {}): CumulativeResults => ({
24
24
  })
25
25
 
26
26
  describe('@owlmeans/llm-common — results block placement', () => {
27
- test('sits after the packages block and before the per-call context', () => {
27
+ test('sits after the packages block and before the context and the per-call tail', () => {
28
28
  expect(PROMPT_BLOCK_ORDER).toEqual([
29
29
  PromptBlock.Role, PromptBlock.Skills, PromptBlock.Packages, PromptBlock.Results,
30
- PromptBlock.Context,
30
+ PromptBlock.Context, PromptBlock.Tail,
31
31
  ])
32
32
  })
33
+
34
+ // The regions partition the order: every block travels in exactly one place, in emission order.
35
+ test('the regions cover every block once, in emission order', () => {
36
+ const regions = [PromptRegion.System, PromptRegion.Project, PromptRegion.Tail]
37
+ expect(regions.flatMap(region => PROMPT_REGIONS[region])).toEqual([...PROMPT_BLOCK_ORDER])
38
+ expect(PROMPT_REGIONS[PromptRegion.Project]).toEqual([PromptBlock.Results, PromptBlock.Context])
39
+ })
40
+ })
41
+
42
+ describe('@owlmeans/llm-common — package purposes', () => {
43
+ // A closed vocabulary that library-manager copies; the list must be the enum, once each.
44
+ test('the declared list holds every purpose exactly once', () => {
45
+ expect(PACKAGE_PURPOSES).toHaveLength(26)
46
+ expect(new Set(PACKAGE_PURPOSES).size).toBe(PACKAGE_PURPOSES.length)
47
+ expect([...PACKAGE_PURPOSES].sort()).toEqual([...Object.values(PackagePurpose)].sort())
48
+ })
33
49
  })
34
50
 
35
51
  describe('@owlmeans/llm-common — rendering a results view', () => {