@owlmeans/llm 0.1.15 → 0.1.16

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 (99) hide show
  1. package/README.md +3 -4
  2. package/agent-meta/manifest.json +9 -9
  3. package/agent-meta/skills/llm/SKILL.md +54 -4
  4. package/agent-meta/skills/llm-prompt-caching/SKILL.md +135 -0
  5. package/build/consts.d.ts +36 -3
  6. package/build/consts.d.ts.map +1 -1
  7. package/build/consts.js +37 -4
  8. package/build/consts.js.map +1 -1
  9. package/build/execution/service.d.ts.map +1 -1
  10. package/build/execution/service.js +8 -3
  11. package/build/execution/service.js.map +1 -1
  12. package/build/execution/types.d.ts +20 -1
  13. package/build/execution/types.d.ts.map +1 -1
  14. package/build/execution/utils.d.ts +12 -1
  15. package/build/execution/utils.d.ts.map +1 -1
  16. package/build/execution/utils.js +22 -0
  17. package/build/execution/utils.js.map +1 -1
  18. package/build/helpers/cache.d.ts +17 -0
  19. package/build/helpers/cache.d.ts.map +1 -0
  20. package/build/helpers/cache.js +22 -0
  21. package/build/helpers/cache.js.map +1 -0
  22. package/build/helpers/index.d.ts +1 -0
  23. package/build/helpers/index.d.ts.map +1 -1
  24. package/build/helpers/index.js +1 -0
  25. package/build/helpers/index.js.map +1 -1
  26. package/build/helpers/spectate.d.ts.map +1 -1
  27. package/build/helpers/spectate.js +7 -0
  28. package/build/helpers/spectate.js.map +1 -1
  29. package/build/index.d.ts +1 -0
  30. package/build/index.d.ts.map +1 -1
  31. package/build/index.js +1 -0
  32. package/build/index.js.map +1 -1
  33. package/build/model.d.ts +1 -1
  34. package/build/model.d.ts.map +1 -1
  35. package/build/model.js +90 -16
  36. package/build/model.js.map +1 -1
  37. package/build/plugins/anthropic.d.ts.map +1 -1
  38. package/build/plugins/anthropic.js +136 -21
  39. package/build/plugins/anthropic.js.map +1 -1
  40. package/build/plugins/openai.d.ts +9 -0
  41. package/build/plugins/openai.d.ts.map +1 -1
  42. package/build/plugins/openai.js +23 -1
  43. package/build/plugins/openai.js.map +1 -1
  44. package/build/plugins/types.d.ts +38 -5
  45. package/build/plugins/types.d.ts.map +1 -1
  46. package/build/prompt/index.d.ts +5 -0
  47. package/build/prompt/index.d.ts.map +1 -0
  48. package/build/prompt/index.js +4 -0
  49. package/build/prompt/index.js.map +1 -0
  50. package/build/prompt/plugins.d.ts +24 -0
  51. package/build/prompt/plugins.d.ts.map +1 -0
  52. package/build/prompt/plugins.js +64 -0
  53. package/build/prompt/plugins.js.map +1 -0
  54. package/build/prompt/render.d.ts +28 -0
  55. package/build/prompt/render.d.ts.map +1 -0
  56. package/build/prompt/render.js +39 -0
  57. package/build/prompt/render.js.map +1 -0
  58. package/build/prompt/service.d.ts +16 -0
  59. package/build/prompt/service.d.ts.map +1 -0
  60. package/build/prompt/service.js +145 -0
  61. package/build/prompt/service.js.map +1 -0
  62. package/build/prompt/types.d.ts +101 -0
  63. package/build/prompt/types.d.ts.map +1 -0
  64. package/build/prompt/types.js +2 -0
  65. package/build/prompt/types.js.map +1 -0
  66. package/build/service.d.ts.map +1 -1
  67. package/build/service.js +3 -0
  68. package/build/service.js.map +1 -1
  69. package/build/types.d.ts +53 -3
  70. package/build/types.d.ts.map +1 -1
  71. package/build/utils/prompt.d.ts +14 -0
  72. package/build/utils/prompt.d.ts.map +1 -1
  73. package/build/utils/prompt.js +32 -0
  74. package/build/utils/prompt.js.map +1 -1
  75. package/package.json +13 -6
  76. package/src/consts.ts +43 -5
  77. package/src/execution/service.ts +9 -3
  78. package/src/execution/types.ts +21 -2
  79. package/src/execution/utils.ts +28 -1
  80. package/src/helpers/cache.ts +33 -0
  81. package/src/helpers/index.ts +1 -0
  82. package/src/helpers/spectate.ts +10 -0
  83. package/src/index.ts +1 -0
  84. package/src/model.ts +119 -16
  85. package/src/plugins/anthropic.ts +159 -20
  86. package/src/plugins/openai.ts +26 -1
  87. package/src/plugins/types.ts +42 -5
  88. package/src/prompt/index.ts +5 -0
  89. package/src/prompt/plugins.ts +69 -0
  90. package/src/prompt/render.ts +48 -0
  91. package/src/prompt/service.ts +194 -0
  92. package/src/prompt/types.ts +114 -0
  93. package/src/service.ts +3 -0
  94. package/src/types.ts +54 -3
  95. package/src/utils/prompt.ts +33 -0
  96. package/tests/execution.spec.ts +42 -0
  97. package/tests/plugins.spec.ts +279 -14
  98. package/tests/prompt.spec.ts +194 -0
  99. package/agent-meta/instructions/llm.instructions.md +0 -66
@@ -1,66 +0,0 @@
1
- ---
2
- description: "How to use @owlmeans/llm — the LLM inference runtime: four-method model, provider plugins, model factory service, and the policy-driven execution abstraction."
3
- applyTo: "**/*.ts, **/*.tsx"
4
- ---
5
- <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
6
-
7
- # @owlmeans/llm
8
-
9
- **Layer:** Core
10
- **Install:** `"@owlmeans/llm": "^0.1.15"` in `dependencies` (plus the `@langchain/*` peers)
11
-
12
- The inference runtime. Everything provider-specific is a **plugin**; the model owns only the
13
- provider-independent parts. Serializable contracts live in `@owlmeans/llm-common`.
14
-
15
- ## Key Exports
16
-
17
- | Export | Description |
18
- |--------|-------------|
19
- | `makeLlmModel(options, spectator)` | `ask` / `talk` / `invoke` / `request`. |
20
- | `makeLlmService` · `appendLlmService` · `llmServiceApi` | Model factory/registry; `llmServiceApi` composes into your own service. |
21
- | `makeExecutionService` · `appendExecutionService` · `executionServiceApi` | Frozen 3-level executions, policy resolution, snapshot/restore/checkpoint. |
22
- | `plugins`, `registerLlmPlugin`, `resolvePlugin`, `pluginOf`, `pluginFor` | Provider-plugin registry (`@owlmeans/llm/plugins`). |
23
- | `anthropicPlugin`, `openAiPlugin`, `compatiblePlugin`, `openAiFamily` | Built-ins; spread `openAiFamily` into a new OpenAI-compatible plugin. |
24
- | `withRetry`, `registerFatalError`, `spectate`, `normalizeInput`, `parseJsonContent`, `coerceToSchema` | Helpers (`@owlmeans/llm/helpers`). |
25
- | `LlmModelError` (retryable), `LlmMissconfiguredError`, `LlmPluginError`, `LlmRetryExceededError` | `ResilientError` family. |
26
-
27
- ## Rules
28
-
29
- - `src/helpers/` is what consumers may use; `src/utils/` is library-private and never
30
- exported. Place a new function on the right side rather than exporting a util for a test.
31
- - Never branch on the provider (`instanceof ChatAnthropic`, `provider === …`) in the model or
32
- the service — put it on the `LlmPlugin` (`build` / `owns` / `family` / `refine` /
33
- `structuredMode` / `toolChoice` / `responseFormat` / `patchCache` / `isFatal`).
34
- - Plugin registration order is load-bearing: `pluginFor` returns the first `owns` match, and
35
- `compatible` precedes `openai` so an unlabelled `ChatOpenAI` gets the conservative
36
- tool-calling behaviour.
37
- - `@langchain/*` are **peer** dependencies — model instances cross the package boundary and
38
- two installed copies are nominally distinct types. Pin one copy in the consumer.
39
- - Extend the execution generically: your own `ExecutionShape`, your collaborator fields in
40
- `collaboratorKeys`. Do not narrow inherited method signatures (contravariance error).
41
-
42
- ## Usage
43
-
44
- ```typescript
45
- import { makeLlmModel, makeLlmService } from '@owlmeans/llm'
46
-
47
- const llm = makeLlmService({ models: () => configs })
48
- const model = makeLlmModel(
49
- { model: llm.getModel('analyst'), purpose: { type: 'analysis' } }, spectator
50
- )
51
- const spec = await model.invoke('Describe the app', SpecSchema, { action: 'spec' })
52
- ```
53
-
54
- Execution resolution precedence: **roleOverride → modelOverride → effort tier →
55
- `LlmService.getModel`**.
56
-
57
- ## Already handled — do not reimplement
58
-
59
- Idle stream deadline · duplicate-final-chunk dedup · output-budget escalation ·
60
- reasoning-cap shrink · same-family fallback model · schema coercion · JSON salvage from
61
- prose · `NullCapture` diagnostics · fatal-error short-circuit.
62
-
63
- ## Depends On
64
-
65
- - `@owlmeans/llm-common`, `@owlmeans/context`, `@owlmeans/error`, `@owlmeans/basic-ids`, `ajv`
66
- - peer `@langchain/core`, `@langchain/openai`, `@langchain/anthropic`