@owlmeans/llm 0.1.18-rc.2 → 0.1.18-rc.21
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 +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/llm/SKILL.md +239 -116
- package/agent-meta/skills/llm-prompt-caching/SKILL.md +37 -3
- package/build/execution/service.d.ts.map +1 -1
- package/build/execution/service.js +46 -11
- package/build/execution/service.js.map +1 -1
- package/build/execution/types.d.ts +72 -12
- package/build/execution/types.d.ts.map +1 -1
- package/build/execution/utils.d.ts.map +1 -1
- package/build/execution/utils.js +15 -9
- package/build/execution/utils.js.map +1 -1
- package/build/helpers/retry.d.ts +14 -0
- package/build/helpers/retry.d.ts.map +1 -1
- package/build/helpers/retry.js +14 -0
- package/build/helpers/retry.js.map +1 -1
- package/build/helpers/spectate.d.ts.map +1 -1
- package/build/helpers/spectate.js +12 -5
- package/build/helpers/spectate.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/model.d.ts +1 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +60 -28
- package/build/model.js.map +1 -1
- package/build/plugins/anthropic.d.ts +40 -0
- package/build/plugins/anthropic.d.ts.map +1 -1
- package/build/plugins/anthropic.js +79 -6
- package/build/plugins/anthropic.js.map +1 -1
- package/build/plugins/openai.d.ts +12 -0
- package/build/plugins/openai.d.ts.map +1 -1
- package/build/plugins/openai.js +29 -3
- package/build/plugins/openai.js.map +1 -1
- package/build/plugins/types.d.ts +7 -0
- package/build/plugins/types.d.ts.map +1 -1
- package/build/prompt/service.d.ts.map +1 -1
- package/build/prompt/service.js +11 -0
- package/build/prompt/service.js.map +1 -1
- package/build/prompt/types.d.ts +20 -0
- package/build/prompt/types.d.ts.map +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +42 -7
- package/build/service.js.map +1 -1
- package/build/types.d.ts +71 -1
- package/build/types.d.ts.map +1 -1
- package/build/utils/config.d.ts +11 -0
- package/build/utils/config.d.ts.map +1 -1
- package/build/utils/config.js +21 -1
- package/build/utils/config.js.map +1 -1
- package/build/utils/null-report.d.ts.map +1 -1
- package/build/utils/null-report.js +9 -1
- package/build/utils/null-report.js.map +1 -1
- package/package.json +13 -13
- package/src/execution/service.ts +46 -11
- package/src/execution/types.ts +77 -13
- package/src/execution/utils.ts +16 -9
- package/src/helpers/retry.ts +16 -0
- package/src/helpers/spectate.ts +14 -5
- package/src/index.ts +4 -2
- package/src/model.ts +77 -27
- package/src/plugins/anthropic.ts +89 -6
- package/src/plugins/openai.ts +33 -3
- package/src/plugins/types.ts +8 -0
- package/src/prompt/service.ts +12 -0
- package/src/prompt/types.ts +20 -0
- package/src/service.ts +53 -7
- package/src/types.ts +71 -1
- package/src/utils/config.ts +23 -1
- package/src/utils/null-report.ts +9 -1
- package/tests/context.ts +3 -0
- package/tests/execution.spec.ts +148 -13
- package/tests/helpers.spec.ts +4 -1
- package/tests/plugins.spec.ts +211 -0
- package/tests/prompt.spec.ts +43 -0
package/build/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA0B,EAAE,IAAsB,EAAiB,EAAE;IAEjG,qFAAqF;IACrF,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAiB,EAAE;QACvE,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI,IA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aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAe,CAC3D,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,GAAM,EACN,OAA0B,EAC1B,KAAK,GAAW,WAAW,EACP,EAAE;IACtB,MAAM,OAAO,GAAG,GAAyB,CAAA;IAEzC,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAEvD,OAAO,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAEtC,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -54,6 +54,12 @@ export interface LlmModelOptions extends LlmLogging {
|
|
|
54
54
|
prompts?: () => PromptService;
|
|
55
55
|
/** File access offered to prompt plugins that resolve knowledge from disk. */
|
|
56
56
|
files?: FileProviderRef;
|
|
57
|
+
/**
|
|
58
|
+
* Cheap model offered to prompt plugins for a single side call while composing —
|
|
59
|
+
* normally `() => executions().utility(exec)`. Omitted, plugins that would use one
|
|
60
|
+
* fall back to whatever they can decide without a model.
|
|
61
|
+
*/
|
|
62
|
+
utility?: () => BaseChatModel | undefined;
|
|
57
63
|
}
|
|
58
64
|
export type ModelMessage = BaseMessage | MessageFieldWithRole;
|
|
59
65
|
export type ModelInputItem = ModelMessage | string;
|
|
@@ -78,6 +84,27 @@ export interface LlmCallOptions {
|
|
|
78
84
|
* should be part of the shared prefix.
|
|
79
85
|
*/
|
|
80
86
|
skills?: string[];
|
|
87
|
+
/**
|
|
88
|
+
* How many failures of this SAME piece of work the caller has already observed — the
|
|
89
|
+
* per-call escalator starts that far up its ladder instead of at the bottom.
|
|
90
|
+
*
|
|
91
|
+
* A caller that validates the OUTPUT (a diff that must apply, a file that must not come
|
|
92
|
+
* back truncated) runs its own retry loop around whole calls, and every one of those
|
|
93
|
+
* calls used to start at attempt 0: same model, same output budget, same answer. Passing
|
|
94
|
+
* the outer attempt here advances both rungs the escalator owns — the `maxTokens`
|
|
95
|
+
* doubling and the {@link FALLBACK_AFTER_ATTEMPTS} switch to `ModelConfig.fallback` — so
|
|
96
|
+
* a repeatedly-rejected call actually reaches the stronger model.
|
|
97
|
+
*
|
|
98
|
+
* Clamped to `retries - 1`; it moves the STARTING rung only and never changes how many
|
|
99
|
+
* attempts this call makes. Unrelated to `ExecutionService.escalate`, which raises the
|
|
100
|
+
* effort tier of an execution before any model is resolved.
|
|
101
|
+
*/
|
|
102
|
+
escalation?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Abort THIS call's retry loop for an error no retry can fix. Consulted before the
|
|
105
|
+
* globally registered resolvers and the provider plugin's `isFatal`.
|
|
106
|
+
*/
|
|
107
|
+
fatal?: (e: unknown) => Error | null;
|
|
81
108
|
}
|
|
82
109
|
export interface LlmAskOptions extends LlmCallOptions {
|
|
83
110
|
ref?: RefferedResult<AIMessage>;
|
|
@@ -132,20 +159,63 @@ export interface TemperatureFactory {
|
|
|
132
159
|
export interface ModelConfig {
|
|
133
160
|
provider?: ModelProvider | string;
|
|
134
161
|
secret?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Which delegate transport answers this model's calls.
|
|
164
|
+
*
|
|
165
|
+
* Only meaningful for {@link ModelProvider.Delegated}: the key the application seated a
|
|
166
|
+
* transport under, so one deployment can hold many at once — one per connected agent — and a
|
|
167
|
+
* config names the one that belongs to its run.
|
|
168
|
+
*/
|
|
169
|
+
delegate?: string;
|
|
135
170
|
alias: string;
|
|
136
171
|
/** Inherit every field of another alias in the same config list. */
|
|
137
172
|
preset?: string;
|
|
138
173
|
model?: string;
|
|
139
174
|
temperature?: number;
|
|
140
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* Initial output-token budget per request (`max_tokens`) — what THIS deployment asks
|
|
177
|
+
* for first, not what the model can do. Clamped to {@link ModelConfig.maxOutput}.
|
|
178
|
+
*/
|
|
141
179
|
maxTokens?: number;
|
|
142
180
|
/**
|
|
143
181
|
* Hard ceiling for output tokens used by the retry escalator. Each retry doubles
|
|
144
182
|
* `maxTokens` toward this cap; without it the escalator uses
|
|
145
183
|
* {@link DEFAULT_MAX_OUTPUT_CAP}, which exceeds many models' real per-request output
|
|
146
184
|
* limit and turns retries into 400 "max_tokens exceeds model limit" errors.
|
|
185
|
+
*
|
|
186
|
+
* This is the budget the PRESET chooses; {@link ModelConfig.maxOutput} is what the
|
|
187
|
+
* provider allows. The effective ceiling is the smaller of the two, so a preset that
|
|
188
|
+
* over-declares is corrected at refine time rather than at the provider.
|
|
147
189
|
*/
|
|
148
190
|
maxTokensCap?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Total context window the model accepts — input plus output. Informational: it is
|
|
193
|
+
* never sent to the provider and the runtime cannot enforce it (the input size is not
|
|
194
|
+
* known at config time). It documents the model and lets the preset test catch a
|
|
195
|
+
* `maxOutput` that could not possibly fit.
|
|
196
|
+
*/
|
|
197
|
+
contextWindow?: number;
|
|
198
|
+
/**
|
|
199
|
+
* What the PROVIDER accepts as output in a single request. Unlike `maxTokens` and
|
|
200
|
+
* `maxTokensCap` — both deployment choices — this is a property of the model behind
|
|
201
|
+
* this alias, and for an aggregated model it is the limit of the `inferenceProvider`
|
|
202
|
+
* actually pinned here, which is often well below what the model can do elsewhere.
|
|
203
|
+
*
|
|
204
|
+
* Hard ceiling: `maxTokens` is clamped to it at build time and the escalator's cap is
|
|
205
|
+
* `min(maxTokensCap, maxOutput)`.
|
|
206
|
+
*
|
|
207
|
+
* A `fallback` that changes `model` MUST redeclare this (and `contextWindow`), because
|
|
208
|
+
* the fallback config inherits every field the patch does not name — otherwise the
|
|
209
|
+
* escalator would size the fallback by the primary's capability.
|
|
210
|
+
*/
|
|
211
|
+
maxOutput?: number;
|
|
212
|
+
/**
|
|
213
|
+
* The context window is SHARED between input and output rather than being an input
|
|
214
|
+
* allowance with a separate output limit (MiniMax M2.x, gpt-oss). Nothing enforces it
|
|
215
|
+
* at runtime; it marks the entry so `maxOutput` is read as "spends the same budget the
|
|
216
|
+
* prompt spends" and keeps presets honest about leaving room for input.
|
|
217
|
+
*/
|
|
218
|
+
combinedWindow?: boolean;
|
|
149
219
|
topP?: number;
|
|
150
220
|
baseUrl?: string;
|
|
151
221
|
organization?: string;
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EACV,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAC1E,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEnE,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAEnC;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC,KAAK,CAAC,EAAE,CAAC,CAAA;IACT,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,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AAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,WAAW,EAAE,CAAA;IAC3B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,kBAAkB;IACpD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAElC,SAAS,EAAE,CAAC,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,CAAA;IAE3D,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,KAAK,IAAI,CAAA;IAEnF,sFAAsF;IACtF,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,aAAa,CAAA;IAEhG,kFAAkF;IAClF,OAAO,EAAE,MAAM,WAAW,EAAE,CAAA;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,UAAU,CAAA;CACtB"}
|
package/build/utils/config.d.ts
CHANGED
|
@@ -10,4 +10,15 @@ import type { ModelConfig } from '../types.js';
|
|
|
10
10
|
export declare const readConfig: (model: BaseChatModel) => Partial<ModelConfig>;
|
|
11
11
|
/** Per-model idle stream timeout (ms), falling back to the package default. */
|
|
12
12
|
export declare const idleTimeout: (config: Partial<ModelConfig>) => number;
|
|
13
|
+
/**
|
|
14
|
+
* The output ceiling the retry escalator may climb to.
|
|
15
|
+
*
|
|
16
|
+
* Two different things claim to bound the output, and only one of them is a fact:
|
|
17
|
+
* `maxTokensCap` is what this deployment budgeted, `maxOutput` is what the provider will
|
|
18
|
+
* accept. Taking the declared cap alone let a preset out-declare its model and turned
|
|
19
|
+
* every escalation into a 400; taking the capability alone would ignore a deliberately
|
|
20
|
+
* frugal budget. So the declared value chooses the ceiling and the capability trims it,
|
|
21
|
+
* and only when neither is stated does {@link DEFAULT_MAX_OUTPUT_CAP} apply.
|
|
22
|
+
*/
|
|
23
|
+
export declare const resolveOutputCap: (config: Partial<ModelConfig>) => number;
|
|
13
24
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAA;AAEhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,aAAa,KAAG,OAAO,CAAC,WAAW,CAGpE,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,WAAW,WAAY,OAAO,CAAC,WAAW,CAAC,KAAG,MACV,CAAA"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAA;AAEhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,aAAa,KAAG,OAAO,CAAC,WAAW,CAGpE,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,WAAW,WAAY,OAAO,CAAC,WAAW,CAAC,KAAG,MACV,CAAA;AAEjD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,WAAY,OAAO,CAAC,WAAW,CAAC,KAAG,MAU/D,CAAA"}
|
package/build/utils/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MODEL_STREAM_TIMEOUT_MS } from '../consts.js';
|
|
1
|
+
import { DEFAULT_MAX_OUTPUT_CAP, MODEL_STREAM_TIMEOUT_MS } from '../consts.js';
|
|
2
2
|
/**
|
|
3
3
|
* Read the original `ModelConfig` back off a model instance. Every plugin's `build`
|
|
4
4
|
* passes `metadata: { config }` on the client constructor, so the config is reachable
|
|
@@ -12,4 +12,24 @@ export const readConfig = (model) => {
|
|
|
12
12
|
};
|
|
13
13
|
/** Per-model idle stream timeout (ms), falling back to the package default. */
|
|
14
14
|
export const idleTimeout = (config) => config.streamTimeout ?? MODEL_STREAM_TIMEOUT_MS;
|
|
15
|
+
/**
|
|
16
|
+
* The output ceiling the retry escalator may climb to.
|
|
17
|
+
*
|
|
18
|
+
* Two different things claim to bound the output, and only one of them is a fact:
|
|
19
|
+
* `maxTokensCap` is what this deployment budgeted, `maxOutput` is what the provider will
|
|
20
|
+
* accept. Taking the declared cap alone let a preset out-declare its model and turned
|
|
21
|
+
* every escalation into a 400; taking the capability alone would ignore a deliberately
|
|
22
|
+
* frugal budget. So the declared value chooses the ceiling and the capability trims it,
|
|
23
|
+
* and only when neither is stated does {@link DEFAULT_MAX_OUTPUT_CAP} apply.
|
|
24
|
+
*/
|
|
25
|
+
export const resolveOutputCap = (config) => {
|
|
26
|
+
const declared = typeof config.maxTokensCap === 'number' && config.maxTokensCap > 0
|
|
27
|
+
? config.maxTokensCap
|
|
28
|
+
: undefined;
|
|
29
|
+
const capability = typeof config.maxOutput === 'number' && config.maxOutput > 0
|
|
30
|
+
? config.maxOutput
|
|
31
|
+
: undefined;
|
|
32
|
+
const cap = declared ?? capability ?? DEFAULT_MAX_OUTPUT_CAP;
|
|
33
|
+
return capability != null ? Math.min(cap, capability) : cap;
|
|
34
|
+
};
|
|
15
35
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE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AS,EAAE,MAAM,CAAA;IACjB,0FAA0F;IAC1F,OAAO,EAAE,aAAa,CAAA;IACtB,mFAAmF;IACnF,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC5B,IAAI,EAAE,oBAAoB,EAAE,CAAA;IAC5B,GAAG,EAAE,cAAc,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAA;IACnD,QAAQ,EAAE,OAAO,CAAA;CAClB;AAKD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,MAAO,gBAAgB,KAAG,WAoErD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,cACV,YAAY,eACV,OAAO,KACjB,gBAAgB,KAClB,OAAO,CAAC,IAAI,CAsBd,CAAA"}
|
|
@@ -12,6 +12,7 @@ export const buildNullReport = (p) => {
|
|
|
12
12
|
const kwargs = p.refined.lc_kwargs;
|
|
13
13
|
const raw = p.raw;
|
|
14
14
|
const responseMeta = raw?.response_metadata;
|
|
15
|
+
const stopReason = raw?.additional_kwargs?.stop_reason;
|
|
15
16
|
const usageMeta = raw?.usage_metadata;
|
|
16
17
|
const toolCalls = raw?.tool_calls;
|
|
17
18
|
return {
|
|
@@ -47,7 +48,14 @@ export const buildNullReport = (p) => {
|
|
|
47
48
|
tool_calls: toolCalls,
|
|
48
49
|
} : null,
|
|
49
50
|
diagnostics: {
|
|
50
|
-
|
|
51
|
+
// Two providers, two places. OpenAI-compatible APIs put it on `response_metadata`;
|
|
52
|
+
// Anthropic never does — it arrives on the `message_delta` event and langchain spreads it
|
|
53
|
+
// into `additional_kwargs.stop_reason`. Reading only the first printed `undefined` for
|
|
54
|
+
// every Anthropic null, hiding the `max_tokens` that explains most of them.
|
|
55
|
+
finishReason: responseMeta?.finish_reason ?? stopReason,
|
|
56
|
+
/** No text block at all — the shape of a completion that was all reasoning. */
|
|
57
|
+
thinkingOnly: Array.isArray(raw?.content) && raw.content.length > 0
|
|
58
|
+
&& !raw.content.some(part => part.type === 'text'),
|
|
51
59
|
inputTokens: usageMeta?.input_tokens ?? responseMeta?.usage?.prompt_tokens,
|
|
52
60
|
outputTokens: usageMeta?.output_tokens ?? responseMeta?.usage?.completion_tokens,
|
|
53
61
|
reasoningTokens: responseMeta?.usage?.reasoning_tokens,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"null-report.js","sourceRoot":"","sources":["../../src/utils/null-report.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAoBtD,4EAA4E;AAC5E,MAAM,aAAa,GAAG,GAAG,CAAA;AAEzB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAmB,EAAe,EAAE;IASlE,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,SAAmB,CAAA;IAC5C,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAA;IACjB,MAAM,YAAY,GAAG,GAAG,EAAE,iBAGb,CAAA;IACb,MAAM,SAAS,GAAG,GAAG,EAAE,cAA+E,CAAA;IACtG,MAAM,SAAS,GAAI,GAAoD,EAAE,UAAU,CAAA;IAEnF,OAAO;QACL,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,EAAE,EAAE,gBAAgB,CAAC,EAAE,CAAC;YACxB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,SAAS;SACpC;QACD,KAAK,EAAE;YACL,oFAAoF;YACpF,EAAE,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,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CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAA;QAC5G,OAAO,IAAK,GAAyB,CAAC,IAAI,IAAI,SAAS,KAAK,IAAI,EAAE,CAAA;IACpE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAElB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CACxC;QACE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW;QAC1E,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,cAAc;KAC3C,EACD,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CACzD,CAAC,CAAA;IAEF,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,CAAA;QACxC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAC,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/llm",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -43,30 +43,30 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@langchain/anthropic": "^1.
|
|
47
|
-
"@langchain/core": "^1.
|
|
48
|
-
"@langchain/openai": "^1.
|
|
46
|
+
"@langchain/anthropic": "^1.5.8",
|
|
47
|
+
"@langchain/core": "^1.2.9",
|
|
48
|
+
"@langchain/openai": "^1.5.10",
|
|
49
49
|
"@owlmeans/dep-config": "workspace:*",
|
|
50
|
-
"@owlmeans/test": "^0.1.18-rc.
|
|
51
|
-
"@types/bun": "^1.
|
|
50
|
+
"@owlmeans/test": "^0.1.18-rc.16",
|
|
51
|
+
"@types/bun": "^1.4.0",
|
|
52
52
|
"@types/node": "^26.1.0",
|
|
53
53
|
"nodemon": "^3.1.14",
|
|
54
54
|
"typescript": "^7.0.2"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
58
|
-
"@owlmeans/basic-ids": "^0.1.18-rc.
|
|
59
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
60
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
61
|
-
"@owlmeans/llm-common": "^0.1.18-rc.
|
|
58
|
+
"@owlmeans/basic-ids": "^0.1.18-rc.17",
|
|
59
|
+
"@owlmeans/context": "^0.1.18-rc.16",
|
|
60
|
+
"@owlmeans/error": "^0.1.18-rc.16",
|
|
61
|
+
"@owlmeans/llm-common": "^0.1.18-rc.20",
|
|
62
62
|
"ajv": "^8.17.1"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@langchain/anthropic": "^1.
|
|
69
|
-
"@langchain/core": "^1.
|
|
70
|
-
"@langchain/openai": "^1.
|
|
68
|
+
"@langchain/anthropic": "^1.5.8",
|
|
69
|
+
"@langchain/core": "^1.2.9",
|
|
70
|
+
"@langchain/openai": "^1.5.10"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/execution/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createService } from '@owlmeans/context'
|
|
2
2
|
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
3
|
-
import { ExecutionLevel } from '@owlmeans/llm-common'
|
|
3
|
+
import { ExecutionEffort, ExecutionLevel, UTILITY_ROLE } from '@owlmeans/llm-common'
|
|
4
4
|
import type { ExecutionState, ModelPolicy, TaskExecutionState } from '@owlmeans/llm-common'
|
|
5
5
|
import { COLLABORATOR_KEYS, EXECUTION_SERVICE } from '../consts.js'
|
|
6
6
|
import type { TemperatureFactory } from '../types.js'
|
|
@@ -82,10 +82,13 @@ export const executionServiceApi = <S extends ExecutionShape = ExecutionShape>(
|
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
forHelper: (parent, input) => {
|
|
85
|
-
const { role, effort, dedication, prompt, ...extras } = input
|
|
85
|
+
const { role, effort, dedication, prompt, output, ...extras } = input
|
|
86
86
|
const localPolicy = effort != null ? mergePolicy(parent.policy, { effort }) : parent.policy
|
|
87
87
|
const scoped = { ...parent, policy: localPolicy } as S['exec']
|
|
88
88
|
const merged = mergePrompt(parent.prompt, prompt)
|
|
89
|
+
// Destructured out of `extras` deliberately: `output` selects a model budget, it is
|
|
90
|
+
// not a field the helper carries around.
|
|
91
|
+
const sizing = output != null ? { maxTokens: output } : undefined
|
|
89
92
|
|
|
90
93
|
const helperExec = {
|
|
91
94
|
...parent,
|
|
@@ -97,8 +100,8 @@ export const executionServiceApi = <S extends ExecutionShape = ExecutionShape>(
|
|
|
97
100
|
policy: localPolicy,
|
|
98
101
|
...(merged != null ? { prompt: merged } : {}),
|
|
99
102
|
role: resolveRole(localPolicy, role),
|
|
100
|
-
model: self().model(scoped, role),
|
|
101
|
-
temperatureFactory: self().temperatureFactory(scoped, role),
|
|
103
|
+
model: self().model(scoped, role, sizing),
|
|
104
|
+
temperatureFactory: self().temperatureFactory(scoped, role, sizing),
|
|
102
105
|
} as unknown as HelperExecution
|
|
103
106
|
// A helper is not resumable — drop a parent task's composed state.
|
|
104
107
|
delete (helperExec as { state?: unknown }).state
|
|
@@ -126,23 +129,55 @@ export const executionServiceApi = <S extends ExecutionShape = ExecutionShape>(
|
|
|
126
129
|
return exec.models().getModel(effectiveRole, clean)
|
|
127
130
|
},
|
|
128
131
|
|
|
129
|
-
|
|
132
|
+
utility: (exec, override) => {
|
|
133
|
+
// Delegated to `model` rather than re-resolved here: the utility tier has to obey
|
|
134
|
+
// the same roleOverride/modelOverride precedence as any other role, and a second
|
|
135
|
+
// copy of that ladder drifts from the first the moment one of them changes.
|
|
136
|
+
const scoped = {
|
|
137
|
+
...exec, policy: mergePolicy(exec.policy, { effort: ExecutionEffort.Economy }),
|
|
138
|
+
} as S['exec']
|
|
139
|
+
|
|
140
|
+
return self().model(scoped, exec.policy.utilityRole ?? UTILITY_ROLE, override)
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
temperatureFactory: (exec, role, baseOverride): TemperatureFactory =>
|
|
130
144
|
temperature =>
|
|
131
145
|
self().model(exec, role, {
|
|
146
|
+
// A budget the helper was built with survives a temperature refinement — the
|
|
147
|
+
// work is the same size whether or not it is being retried creatively.
|
|
148
|
+
...(typeof baseOverride === 'object' ? baseOverride : {}),
|
|
132
149
|
...(temperature != null ? { temperature } : {}),
|
|
133
150
|
...(temperature != null && temperature > 0.2 ? { topP: 0.8 } : {}),
|
|
134
151
|
}),
|
|
135
152
|
|
|
136
153
|
use: plugin => {
|
|
137
|
-
|
|
154
|
+
// Seated by alias when it has one: mixins compose, and a layer wired twice would otherwise
|
|
155
|
+
// answer twice — silently, since the first usable answer wins.
|
|
156
|
+
const at = plugin.alias != null
|
|
157
|
+
? plugins.findIndex(entry => entry.alias === plugin.alias)
|
|
158
|
+
: -1
|
|
159
|
+
if (at < 0) {
|
|
160
|
+
plugins.push(plugin)
|
|
161
|
+
} else {
|
|
162
|
+
plugins[at] = plugin
|
|
163
|
+
}
|
|
138
164
|
},
|
|
139
165
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
166
|
+
advise: async (exec, request) => {
|
|
167
|
+
for (const plugin of plugins) {
|
|
168
|
+
if (plugin.advise == null) continue
|
|
169
|
+
try {
|
|
170
|
+
const advice = await plugin.advise(exec, request)
|
|
171
|
+
if (advice != null && advice.trim() !== '') {
|
|
172
|
+
return advice
|
|
173
|
+
}
|
|
174
|
+
} catch (e) {
|
|
175
|
+
// Advice is an optimization. A broken advisor must never take the work with it.
|
|
176
|
+
console.warn(`Execution advisor failed for "${request.kind}":`, e)
|
|
177
|
+
}
|
|
143
178
|
}
|
|
144
|
-
|
|
145
|
-
|
|
179
|
+
|
|
180
|
+
return null
|
|
146
181
|
},
|
|
147
182
|
|
|
148
183
|
snapshot: exec => {
|
package/src/execution/types.ts
CHANGED
|
@@ -79,6 +79,16 @@ export interface HelperExecutionInput {
|
|
|
79
79
|
prompt?: PromptPolicy
|
|
80
80
|
/** Refines `purpose.dedication`. */
|
|
81
81
|
dedication?: string
|
|
82
|
+
/**
|
|
83
|
+
* Initial output-token budget for this helper's model (`ModelConfig.maxTokens`), for
|
|
84
|
+
* work whose ONE answer is genuinely large — a whole source file rather than a decision.
|
|
85
|
+
*
|
|
86
|
+
* The role's preset value sizes the common case; a helper that routinely needs more
|
|
87
|
+
* would otherwise spend its first attempt producing a truncated answer and only reach a
|
|
88
|
+
* workable budget through the retry escalator, which doubles from this number. Clamped
|
|
89
|
+
* to the provider's `maxOutput` and preserved across `temperatureFactory`.
|
|
90
|
+
*/
|
|
91
|
+
output?: number
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
/** Collaborators re-attached to a state that was restored from storage. */
|
|
@@ -89,16 +99,41 @@ export interface RestoreCollaborators {
|
|
|
89
99
|
}
|
|
90
100
|
|
|
91
101
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
* What a performer wants to know before it acts. Runtime-only — never snapshotted, so it
|
|
103
|
+
* carries whatever the advisor and its callers agree on.
|
|
104
|
+
*/
|
|
105
|
+
export interface AdviceRequest {
|
|
106
|
+
/** Which advisor is being asked; an advisor that does not own this kind returns null. */
|
|
107
|
+
kind: string
|
|
108
|
+
/** The work at hand, in the caller's own words — normally the assignment text. */
|
|
109
|
+
task: string
|
|
110
|
+
/** Anything that narrows the answer (a subproject, a path prefix, an entity). */
|
|
111
|
+
hints?: Record<string, unknown>
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Extension seam. A plugin ANSWERS a performer's question about its surroundings.
|
|
116
|
+
*
|
|
117
|
+
* It used to carry a checkpoint pair as well (`onCheckpoint`/`onRestore`), and that is gone: an
|
|
118
|
+
* execution is a bundle of collaborators and domain context, not a workflow position, and the only
|
|
119
|
+
* position it ever carried was three optional fields nothing ever read back. Recoverable work is a
|
|
120
|
+
* PIPELINE — `@owlmeans/agent`'s `makePipeline` — whose steps are named, whose state is scalars and
|
|
121
|
+
* keys, and whose run row is a single authority on where it stands. Two mechanisms answering "where
|
|
122
|
+
* is this run" is two half-truths, which is exactly what this deletion removes.
|
|
96
123
|
*/
|
|
97
124
|
export interface ExecutionPlugin {
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Identity for de-duplication. A plugin registered twice — two `append*` calls composing the
|
|
127
|
+
* same layer — would otherwise answer twice, and the first usable answer wins, so the duplicate
|
|
128
|
+
* is silent rather than loud.
|
|
129
|
+
*/
|
|
130
|
+
alias?: string
|
|
131
|
+
/**
|
|
132
|
+
* Answer a performer's question about the project it is working in. Return the text to
|
|
133
|
+
* hand the model, or `null` when this plugin does not own the request's `kind` — or
|
|
134
|
+
* cannot answer it. Advice is advisory: a `null` never blocks the work.
|
|
135
|
+
*/
|
|
136
|
+
advise?: (exec: Execution, request: AdviceRequest) => Promise<string | null>
|
|
102
137
|
}
|
|
103
138
|
|
|
104
139
|
/**
|
|
@@ -134,15 +169,44 @@ export interface ExecutionService<S extends ExecutionShape = ExecutionShape> ext
|
|
|
134
169
|
|
|
135
170
|
// Model resolution (policy-aware)
|
|
136
171
|
model: (exec: S['exec'], role?: ModelRole, override?: ModelConfigOverride) => BaseChatModel
|
|
137
|
-
|
|
172
|
+
/**
|
|
173
|
+
* The cheap model for work that is not the work — a relevance pick, a classification, a
|
|
174
|
+
* one-line judgement a plugin needs before the real call can be shaped.
|
|
175
|
+
*
|
|
176
|
+
* Resolves `policy.utilityRole ?? UTILITY_ROLE` at {@link ExecutionEffort.Economy} through
|
|
177
|
+
* the SAME ladder as {@link model}, so `roleOverrides` and `modelOverrides` govern it
|
|
178
|
+
* exactly as they govern every other role. The effort floor is local: the execution it
|
|
179
|
+
* was asked on keeps its own tier.
|
|
180
|
+
*/
|
|
181
|
+
utility: (exec: S['exec'], override?: ModelConfigOverride) => BaseChatModel
|
|
182
|
+
/**
|
|
183
|
+
* A factory that re-resolves the same role at another temperature. `baseOverride` is
|
|
184
|
+
* layered UNDER the temperature patch, so a caller-chosen budget (see
|
|
185
|
+
* `HelperExecutionInput.output`) survives the refinement.
|
|
186
|
+
*/
|
|
187
|
+
temperatureFactory: (
|
|
188
|
+
exec: S['exec'], role?: ModelRole, baseOverride?: ModelConfigOverride
|
|
189
|
+
) => TemperatureFactory
|
|
138
190
|
|
|
139
|
-
//
|
|
140
|
-
/** Register
|
|
191
|
+
// Serialization
|
|
192
|
+
/** Register an execution plugin (advice). Seated by `alias` when it carries one. */
|
|
141
193
|
use: (plugin: ExecutionPlugin) => void
|
|
142
|
-
/**
|
|
143
|
-
|
|
194
|
+
/**
|
|
195
|
+
* The JSON-safe half of an execution — everything that is not a collaborator.
|
|
196
|
+
*
|
|
197
|
+
* A transport-level convenience, not a workflow position: nothing here says where a run has got
|
|
198
|
+
* to, and nothing should. See {@link ExecutionPlugin}.
|
|
199
|
+
*/
|
|
144
200
|
snapshot: (exec: S['exec']) => ExecutionState
|
|
145
201
|
restore: (state: ExecutionState, collaborators?: S['collaborators']) => S['exec']
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Ask the registered plugins about the project this execution runs in. Plugins are
|
|
205
|
+
* consulted in registration order and the FIRST usable answer wins, so one advisor owns
|
|
206
|
+
* each `kind` rather than several concatenating half-answers. Never throws: a plugin
|
|
207
|
+
* that fails is skipped, and `null` means nobody answered.
|
|
208
|
+
*/
|
|
209
|
+
advise: (exec: S['exec'], request: AdviceRequest) => Promise<string | null>
|
|
146
210
|
}
|
|
147
211
|
|
|
148
212
|
export interface ExecutionServiceOptions {
|
package/src/execution/utils.ts
CHANGED
|
@@ -9,15 +9,22 @@ import type { Execution, TaskExecution } from './types.js'
|
|
|
9
9
|
export const freeze = <T extends object>(o: T): Readonly<T> => Object.freeze(o)
|
|
10
10
|
|
|
11
11
|
/** Overlay a partial policy onto a base one. Override maps are merged, not replaced. */
|
|
12
|
-
export const mergePolicy = (base: ModelPolicy, patch: Partial<ModelPolicy>): ModelPolicy =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
export const mergePolicy = (base: ModelPolicy, patch: Partial<ModelPolicy>): ModelPolicy => {
|
|
13
|
+
const utilityRole = patch.utilityRole ?? base.utilityRole
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
effort: patch.effort ?? base.effort,
|
|
17
|
+
roleOverrides: patch.roleOverrides != null || base.roleOverrides != null
|
|
18
|
+
? { ...base.roleOverrides, ...patch.roleOverrides }
|
|
19
|
+
: undefined,
|
|
20
|
+
modelOverrides: patch.modelOverrides != null || base.modelOverrides != null
|
|
21
|
+
? { ...base.modelOverrides, ...patch.modelOverrides }
|
|
22
|
+
: undefined,
|
|
23
|
+
// Added only when it exists, unlike the maps above: a project that never names a
|
|
24
|
+
// cheap tier must not gain a `utilityRole` key it would then carry into every snapshot.
|
|
25
|
+
...(utilityRole != null ? { utilityRole } : {}),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* Overlay a prompt policy onto the one inherited from the parent level.
|
package/src/helpers/retry.ts
CHANGED
|
@@ -16,6 +16,22 @@ export const registerFatalError = (resolver: FatalErrorResolver): void => {
|
|
|
16
16
|
resolvers.push(resolver)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The one answer to "can any retry fix this?", exported so callers above the retry loop can ask it.
|
|
21
|
+
*
|
|
22
|
+
* A retry loop is not the only place that decides to carry on: a fix ladder rescues a failed
|
|
23
|
+
* repair and climbs to a stronger model, an agent runner catches a round that threw and reports
|
|
24
|
+
* "gave up". Both of those are right for a model that answered badly and wrong for a budget that
|
|
25
|
+
* ran out — and a blanket `catch` cannot tell them apart, so an exhausted balance became more
|
|
26
|
+
* expensive calls rather than a halt. Rather than each caller re-deriving the rule (and drifting
|
|
27
|
+
* from it), they ask the same resolvers, in the same order, that `withRetry` uses.
|
|
28
|
+
*
|
|
29
|
+
* Returns the error to abort WITH — a resolver may unwrap a carrier and hand back the real
|
|
30
|
+
* cause — or `null` when nothing considers it terminal.
|
|
31
|
+
*/
|
|
32
|
+
export const isFatalError = (e: unknown, fatal?: FatalErrorResolver): Error | null =>
|
|
33
|
+
resolveFatal(e, fatal)
|
|
34
|
+
|
|
19
35
|
const resolveFatal = (e: unknown, fatal?: FatalErrorResolver): Error | null => {
|
|
20
36
|
const own = fatal?.(e)
|
|
21
37
|
if (own != null) return own
|