@noetic-tools/core 5.19.1 → 5.20.0-next.1
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/dist/adapters/openrouter.js +5 -0
- package/dist/builders/control-flow-builders.d.ts +15 -6
- package/dist/builders/control-flow-builders.js +8 -0
- package/dist/builders/decide-builders.d.ts +2 -5
- package/dist/builders/dynamic-workflow.d.ts +16 -1
- package/dist/builders/dynamic-workflow.js +222 -11
- package/dist/builders/every.d.ts +3 -3
- package/dist/builders/every.js +2 -1
- package/dist/builders/provide-builder.d.ts +3 -2
- package/dist/builders/provide-builder.js +2 -1
- package/dist/builders/sequence.d.ts +14 -0
- package/dist/builders/sequence.js +103 -0
- package/dist/builders/spawn-builder.d.ts +3 -2
- package/dist/builders/spawn-builder.js +3 -2
- package/dist/builders/step-builders.d.ts +80 -1
- package/dist/builders/step-builders.js +115 -1
- package/dist/builders/verify-builder.d.ts +79 -0
- package/dist/builders/verify-builder.js +69 -0
- package/dist/builders/workflow-child-nodes.d.ts +21 -0
- package/dist/builders/workflow-child-nodes.js +335 -0
- package/dist/builders/workflow-connection-nodes.d.ts +17 -0
- package/dist/builders/workflow-connection-nodes.js +160 -0
- package/dist/builders/workflow-connections.d.ts +90 -0
- package/dist/builders/workflow-connections.js +560 -0
- package/dist/builders/workflow-control-nodes.d.ts +13 -0
- package/dist/builders/workflow-control-nodes.js +213 -0
- package/dist/builders/workflow-hydrator.d.ts +44 -3
- package/dist/builders/workflow-hydrator.js +53 -495
- package/dist/builders/workflow-verify.d.ts +19 -0
- package/dist/builders/workflow-verify.js +194 -0
- package/dist/conditions/conditions.d.ts +7 -5
- package/dist/conditions/conditions.js +7 -4
- package/dist/connections/blobs.d.ts +33 -0
- package/dist/connections/blobs.js +77 -0
- package/dist/connections/cron-schedule.d.ts +32 -0
- package/dist/connections/cron-schedule.js +213 -0
- package/dist/connections/durability.d.ts +65 -0
- package/dist/connections/durability.js +54 -0
- package/dist/connections/errors.d.ts +30 -0
- package/dist/connections/errors.js +100 -0
- package/dist/connections/event-stream.d.ts +24 -0
- package/dist/connections/event-stream.js +176 -0
- package/dist/connections/gates.d.ts +94 -0
- package/dist/connections/gates.js +271 -0
- package/dist/connections/glob.d.ts +10 -0
- package/dist/connections/glob.js +46 -0
- package/dist/connections/handle.d.ts +22 -0
- package/dist/connections/handle.js +84 -0
- package/dist/connections/harness-wiring.d.ts +52 -0
- package/dist/connections/harness-wiring.js +143 -0
- package/dist/connections/in-memory-connection.d.ts +147 -0
- package/dist/connections/in-memory-connection.js +593 -0
- package/dist/connections/index.d.ts +34 -0
- package/dist/connections/index.js +23 -0
- package/dist/connections/json-schema.d.ts +28 -0
- package/dist/connections/json-schema.js +338 -0
- package/dist/connections/model-tools.d.ts +46 -0
- package/dist/connections/model-tools.js +466 -0
- package/dist/connections/negotiation.d.ts +30 -0
- package/dist/connections/negotiation.js +159 -0
- package/dist/connections/policy.d.ts +21 -0
- package/dist/connections/policy.js +34 -0
- package/dist/connections/pool.d.ts +111 -0
- package/dist/connections/pool.js +339 -0
- package/dist/connections/refs.d.ts +74 -0
- package/dist/connections/refs.js +316 -0
- package/dist/connections/registry-types.d.ts +141 -0
- package/dist/connections/registry-types.js +14 -0
- package/dist/connections/registry.d.ts +125 -0
- package/dist/connections/registry.js +775 -0
- package/dist/connections/secrets.d.ts +59 -0
- package/dist/connections/secrets.js +153 -0
- package/dist/connections/settle.d.ts +9 -0
- package/dist/connections/settle.js +26 -0
- package/dist/connections/sources.d.ts +27 -0
- package/dist/connections/sources.js +300 -0
- package/dist/connections/triggers.d.ts +78 -0
- package/dist/connections/triggers.js +310 -0
- package/dist/connections/values.d.ts +26 -0
- package/dist/connections/values.js +93 -0
- package/dist/connections/views.d.ts +31 -0
- package/dist/connections/views.js +176 -0
- package/dist/expression/check.js +80 -1
- package/dist/expression/jsonata.d.ts +14 -4
- package/dist/expression/jsonata.js +27 -9
- package/dist/expression/step-outputs.d.ts +25 -0
- package/dist/expression/step-outputs.js +78 -0
- package/dist/harness/agent-harness.d.ts +69 -166
- package/dist/harness/agent-harness.js +170 -262
- package/dist/harness/call-span-collector.d.ts +33 -0
- package/dist/harness/call-span-collector.js +83 -0
- package/dist/harness/connection-gate.d.ts +78 -0
- package/dist/harness/connection-gate.js +169 -0
- package/dist/harness/deps/interpreter.d.ts +1 -0
- package/dist/harness/deps/interpreter.js +1 -0
- package/dist/harness/deps/runtime.d.ts +1 -1
- package/dist/harness/deps/types.d.ts +1 -1
- package/dist/harness/harness-options.d.ts +153 -0
- package/dist/harness/harness-options.js +36 -0
- package/dist/harness/harness-tracing.d.ts +16 -0
- package/dist/harness/harness-tracing.js +35 -0
- package/dist/harness/llm-client.d.ts +71 -0
- package/dist/harness/llm-client.js +218 -0
- package/dist/harness/model-call.d.ts +2 -7
- package/dist/harness/model-call.js +21 -549
- package/dist/harness/model-request.d.ts +42 -0
- package/dist/harness/model-request.js +159 -0
- package/dist/harness/model-stream.d.ts +39 -0
- package/dist/harness/model-stream.js +131 -0
- package/dist/harness/model-tool-round.d.ts +37 -0
- package/dist/harness/model-tool-round.js +197 -0
- package/dist/harness/spend.d.ts +2 -0
- package/dist/harness/spend.js +5 -1
- package/dist/index.d.ts +31 -6
- package/dist/index.js +18 -1
- package/dist/interpreter/connection-steps.d.ts +194 -0
- package/dist/interpreter/connection-steps.js +537 -0
- package/dist/interpreter/execute-action.d.ts +2 -8
- package/dist/interpreter/execute-action.js +3 -178
- package/dist/interpreter/execute-call.d.ts +19 -0
- package/dist/interpreter/execute-call.js +99 -0
- package/dist/interpreter/execute-control.d.ts +6 -1
- package/dist/interpreter/execute-control.js +14 -0
- package/dist/interpreter/execute-invoke-tool.d.ts +11 -0
- package/dist/interpreter/execute-invoke-tool.js +183 -0
- package/dist/interpreter/execute-verify.d.ts +21 -0
- package/dist/interpreter/execute-verify.js +391 -0
- package/dist/interpreter/execute-wait.d.ts +21 -0
- package/dist/interpreter/execute-wait.js +233 -0
- package/dist/interpreter/execute.js +24 -133
- package/dist/interpreter/step-kind-dispatch.d.ts +24 -0
- package/dist/interpreter/step-kind-dispatch.js +157 -0
- package/dist/interpreter/step-walk.d.ts +2 -0
- package/dist/interpreter/step-walk.js +24 -0
- package/dist/interpreter/verify-host.d.ts +40 -0
- package/dist/interpreter/verify-host.js +245 -0
- package/dist/runtime/durable/step-ledger.d.ts +31 -1
- package/dist/runtime/durable/step-ledger.js +87 -1
- package/dist/runtime/in-memory-artifact-store.d.ts +24 -0
- package/dist/runtime/in-memory-artifact-store.js +240 -0
- package/dist/schemas/workflow.d.ts +2 -2
- package/dist/schemas/workflow.js +1 -1
- package/dist/util/harness-internals.d.ts +23 -0
- package/dist/util/harness-internals.js +35 -0
- package/package.json +3 -3
- package/schema/noetic-workflow.schema.json +1170 -92
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ItemSchemaRegistry, NoeticConfigError } from '@noetic-tools/types';
|
|
2
|
+
import { OpenRouterSdk } from './deps/adapters.js';
|
|
3
|
+
import type { AgentHarnessContract, CallModelRequest, ContextCacheConfig, ContextData, DecideRequest, DecideResponse, LLMResponse, LlmProviderConfig, Step, TraceExporter } from './deps/types.js';
|
|
4
|
+
import type { Spend } from './spend.js';
|
|
5
|
+
/** Env vars consulted when resolving the LLM client (read defensively so the
|
|
6
|
+
* harness also works in runtimes without a `process` global, e.g. the browser). */
|
|
7
|
+
export interface LlmEnv {
|
|
8
|
+
noeticApiKey?: string;
|
|
9
|
+
noeticBaseUrl?: string;
|
|
10
|
+
openrouterApiKey?: string;
|
|
11
|
+
}
|
|
12
|
+
/** @public Effective client options resolved from config + environment. */
|
|
13
|
+
export interface ResolvedLlmClient {
|
|
14
|
+
apiKey: string;
|
|
15
|
+
/** Undefined means "use the SDK's default OpenRouter base URL". */
|
|
16
|
+
serverURL?: string;
|
|
17
|
+
cache: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** What the harness's model gateway is built from. */
|
|
20
|
+
export interface LlmGatewayOptions {
|
|
21
|
+
agentName: string;
|
|
22
|
+
providerConfig?: LlmProviderConfig;
|
|
23
|
+
contextCache?: ContextCacheConfig;
|
|
24
|
+
/** Paid dispatch records; when present, both clients note each call's generation id. */
|
|
25
|
+
spend?: Spend;
|
|
26
|
+
callModelOverride?: (request: CallModelRequest) => Promise<LLMResponse>;
|
|
27
|
+
decideOverride?: (request: DecideRequest) => Promise<DecideResponse>;
|
|
28
|
+
streamIdleTimeoutMs: number;
|
|
29
|
+
}
|
|
30
|
+
/** The per-call parts of a model call the harness supplies. */
|
|
31
|
+
export interface ModelCallHost {
|
|
32
|
+
itemSchemas: ItemSchemaRegistry;
|
|
33
|
+
harness: AgentHarnessContract;
|
|
34
|
+
traceExporter: TraceExporter;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the effective LLM client options from the provider config + environment.
|
|
38
|
+
* Defaults to the Noetic platform (`provider: 'noetic'`): the `'noetic'` provider
|
|
39
|
+
* authenticates with `NOETIC_API_KEY` and targets the Noetic platform base URL,
|
|
40
|
+
* while `'openrouter'` authenticates with `OPENROUTER_API_KEY` and uses the SDK's
|
|
41
|
+
* default OpenRouter endpoint. Returns undefined when no API key is available.
|
|
42
|
+
* Exported for testing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveLlmClient(config: LlmProviderConfig | undefined, env: LlmEnv): ResolvedLlmClient | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The harness's route to its model provider: the provider clients resolved from
|
|
47
|
+
* config + environment, the test overrides, and the `callModel` / `decide` calls
|
|
48
|
+
* made through them.
|
|
49
|
+
*/
|
|
50
|
+
export declare class LlmGateway {
|
|
51
|
+
#private;
|
|
52
|
+
private readonly client?;
|
|
53
|
+
/**
|
|
54
|
+
* SDK 1.x client for the endpoints the agent's client predates: decisions, model
|
|
55
|
+
* prices, and generation lookups.
|
|
56
|
+
*/
|
|
57
|
+
readonly sdkClient?: OpenRouterSdk;
|
|
58
|
+
/** Model id → whether it answers natively as a decision model. */
|
|
59
|
+
private readonly decisionModels;
|
|
60
|
+
constructor(options: LlmGatewayOptions);
|
|
61
|
+
callModel(request: CallModelRequest, host: ModelCallHost): Promise<LLMResponse>;
|
|
62
|
+
decide(request: DecideRequest, callModel: (request: CallModelRequest) => Promise<LLMResponse>): Promise<DecideResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* The error to fail with when `step` calls a model this harness has no
|
|
65
|
+
* credentials for, else undefined. Checked before any step runs so a missing
|
|
66
|
+
* provider fails fast instead of after earlier steps' side effects. Steps the
|
|
67
|
+
* walk cannot see (dynamic branches) still hit the same error lazily at their
|
|
68
|
+
* model call.
|
|
69
|
+
*/
|
|
70
|
+
missingModelFor<I, O>(step: Step<ContextData, I, O>): NoeticConfigError | undefined;
|
|
71
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { frameworkCast } from '@noetic-tools/types';
|
|
2
|
+
import { callDecide } from './decide-call.js';
|
|
3
|
+
import { HTTPClient, OpenRouter, OpenRouterSdk } from './deps/adapters.js';
|
|
4
|
+
import { someStep } from './deps/interpreter.js';
|
|
5
|
+
import { AgentHarnessModelCaller, noLlmProviderError } from './model-call.js';
|
|
6
|
+
import { DISPATCH_HEADER, GENERATION_HEADER } from './spend.js';
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region Client resolution
|
|
9
|
+
/** The Noetic platform's OpenAI-Responses-compatible inference base URL. */
|
|
10
|
+
const NOETIC_DEFAULT_BASE_URL = 'https://platform.noetic.tools/v1';
|
|
11
|
+
function readLlmEnv() {
|
|
12
|
+
const processValue = 'process' in globalThis ? globalThis.process : undefined;
|
|
13
|
+
const env = typeof processValue === 'object' && processValue !== null && 'env' in processValue
|
|
14
|
+
? processValue.env
|
|
15
|
+
: undefined;
|
|
16
|
+
if (typeof env !== 'object' || env === null) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
const str = (value) => typeof value === 'string' ? value : undefined;
|
|
20
|
+
return {
|
|
21
|
+
noeticApiKey: 'NOETIC_API_KEY' in env ? str(env.NOETIC_API_KEY) : undefined,
|
|
22
|
+
noeticBaseUrl: 'NOETIC_BASE_URL' in env ? str(env.NOETIC_BASE_URL) : undefined,
|
|
23
|
+
openrouterApiKey: 'OPENROUTER_API_KEY' in env ? str(env.OPENROUTER_API_KEY) : undefined,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the effective LLM client options from the provider config + environment.
|
|
28
|
+
* Defaults to the Noetic platform (`provider: 'noetic'`): the `'noetic'` provider
|
|
29
|
+
* authenticates with `NOETIC_API_KEY` and targets the Noetic platform base URL,
|
|
30
|
+
* while `'openrouter'` authenticates with `OPENROUTER_API_KEY` and uses the SDK's
|
|
31
|
+
* default OpenRouter endpoint. Returns undefined when no API key is available.
|
|
32
|
+
* Exported for testing.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveLlmClient(config, env) {
|
|
35
|
+
const provider = config?.provider ?? 'noetic';
|
|
36
|
+
const apiKey = config?.apiKey ?? (provider === 'noetic' ? env.noeticApiKey : env.openrouterApiKey);
|
|
37
|
+
if (!apiKey) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const serverURL = provider === 'noetic'
|
|
41
|
+
? (config?.baseUrl ?? env.noeticBaseUrl ?? NOETIC_DEFAULT_BASE_URL)
|
|
42
|
+
: config?.baseUrl;
|
|
43
|
+
return {
|
|
44
|
+
apiKey,
|
|
45
|
+
serverURL,
|
|
46
|
+
cache: config?.cache ?? false,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Ask the provider to cache the prompt prefix.
|
|
51
|
+
*
|
|
52
|
+
* Anthropic caching is opt-in — without a breakpoint it caches nothing however
|
|
53
|
+
* stable the prefix is, measured against live models. OpenRouter accepts a
|
|
54
|
+
* `cache_control` directive on the request and places the breakpoints itself;
|
|
55
|
+
* providers that cache on their own (OpenAI, Gemini) ignore it.
|
|
56
|
+
*
|
|
57
|
+
* It has to be injected here rather than passed with the other request fields:
|
|
58
|
+
* the SDK validates the request against a generated schema that drops keys it
|
|
59
|
+
* does not know, and `cache_control` is one of them.
|
|
60
|
+
*/
|
|
61
|
+
async function addCacheBreakpoint(request) {
|
|
62
|
+
const body = await request.clone().text();
|
|
63
|
+
if (!body) {
|
|
64
|
+
return request;
|
|
65
|
+
}
|
|
66
|
+
let payload;
|
|
67
|
+
try {
|
|
68
|
+
payload = JSON.parse(body);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return request;
|
|
72
|
+
}
|
|
73
|
+
if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {
|
|
74
|
+
return request;
|
|
75
|
+
}
|
|
76
|
+
return new Request(request, {
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
...payload,
|
|
79
|
+
cache_control: {
|
|
80
|
+
type: 'ephemeral',
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function createClient(config, contextCache, http) {
|
|
86
|
+
const resolved = resolveLlmClient(config, readLlmEnv());
|
|
87
|
+
if (!resolved) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const options = {
|
|
91
|
+
apiKey: resolved.apiKey,
|
|
92
|
+
};
|
|
93
|
+
if (resolved.serverURL) {
|
|
94
|
+
options.serverURL = resolved.serverURL;
|
|
95
|
+
}
|
|
96
|
+
if (http) {
|
|
97
|
+
// The agent bundles an older SDK whose `HTTPClient` class is nominally different;
|
|
98
|
+
// the agent calls only `request()` on it, which both versions share.
|
|
99
|
+
options.httpClient = frameworkCast(http);
|
|
100
|
+
}
|
|
101
|
+
// A cache write costs more than a plain read, so the breakpoint only pays off
|
|
102
|
+
// when something is holding the prefix still — which is what anchoring does.
|
|
103
|
+
const wantsBreakpoint = contextCache?.enabled !== false;
|
|
104
|
+
if (!resolved.cache && !wantsBreakpoint) {
|
|
105
|
+
return new OpenRouter(options);
|
|
106
|
+
}
|
|
107
|
+
return new OpenRouter({
|
|
108
|
+
...options,
|
|
109
|
+
hooks: {
|
|
110
|
+
beforeRequest: async (_ctx, request) => {
|
|
111
|
+
if (resolved.cache) {
|
|
112
|
+
// Serve identical model calls from OpenRouter's own response cache
|
|
113
|
+
// without re-billing (deterministic re-runs).
|
|
114
|
+
request.headers.set('X-OpenRouter-Cache', 'true');
|
|
115
|
+
}
|
|
116
|
+
return wantsBreakpoint ? addCacheBreakpoint(request) : request;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* An HTTP client that saves a paid call's generation id the moment its headers
|
|
123
|
+
* arrive. The SDK awaits the hook before it reads the body, so a call cut off after
|
|
124
|
+
* its headers can still be priced. Both the model client and the decisions client
|
|
125
|
+
* send through it; requests without a dispatch header pass untouched.
|
|
126
|
+
*/
|
|
127
|
+
function generationHook(spend) {
|
|
128
|
+
return new HTTPClient().addHook('response', async (res, req) => {
|
|
129
|
+
const dispatchId = req.headers.get(DISPATCH_HEADER);
|
|
130
|
+
const generationId = res.headers.get(GENERATION_HEADER);
|
|
131
|
+
// An error response is retried or refused; only a success carries the call's id.
|
|
132
|
+
if (res.ok && dispatchId && generationId) {
|
|
133
|
+
await spend.noteGeneration(dispatchId, generationId);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function createSdkClient(config, http) {
|
|
138
|
+
const resolved = resolveLlmClient(config, readLlmEnv());
|
|
139
|
+
if (!resolved) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
return new OpenRouterSdk({
|
|
143
|
+
apiKey: resolved.apiKey,
|
|
144
|
+
serverURL: resolved.serverURL,
|
|
145
|
+
...(http
|
|
146
|
+
? {
|
|
147
|
+
httpClient: http,
|
|
148
|
+
}
|
|
149
|
+
: {}),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region LlmGateway
|
|
154
|
+
/**
|
|
155
|
+
* The harness's route to its model provider: the provider clients resolved from
|
|
156
|
+
* config + environment, the test overrides, and the `callModel` / `decide` calls
|
|
157
|
+
* made through them.
|
|
158
|
+
*/
|
|
159
|
+
export class LlmGateway {
|
|
160
|
+
#options;
|
|
161
|
+
client;
|
|
162
|
+
/**
|
|
163
|
+
* SDK 1.x client for the endpoints the agent's client predates: decisions, model
|
|
164
|
+
* prices, and generation lookups.
|
|
165
|
+
*/
|
|
166
|
+
sdkClient;
|
|
167
|
+
/** Model id → whether it answers natively as a decision model. */
|
|
168
|
+
decisionModels = new Map();
|
|
169
|
+
constructor(options) {
|
|
170
|
+
this.#options = options;
|
|
171
|
+
const http = options.spend ? generationHook(options.spend) : undefined;
|
|
172
|
+
this.client = options.callModelOverride
|
|
173
|
+
? undefined
|
|
174
|
+
: createClient(options.providerConfig, options.contextCache, http);
|
|
175
|
+
this.sdkClient = options.callModelOverride
|
|
176
|
+
? undefined
|
|
177
|
+
: createSdkClient(options.providerConfig, http);
|
|
178
|
+
}
|
|
179
|
+
callModel(request, host) {
|
|
180
|
+
return new AgentHarnessModelCaller({
|
|
181
|
+
agentName: this.#options.agentName,
|
|
182
|
+
itemSchemas: host.itemSchemas,
|
|
183
|
+
client: this.client,
|
|
184
|
+
callModelOverride: this.#options.callModelOverride,
|
|
185
|
+
streamIdleTimeoutMs: this.#options.streamIdleTimeoutMs,
|
|
186
|
+
harness: host.harness,
|
|
187
|
+
traceExporter: host.traceExporter,
|
|
188
|
+
spend: this.#options.spend,
|
|
189
|
+
}).callModel(request);
|
|
190
|
+
}
|
|
191
|
+
decide(request, callModel) {
|
|
192
|
+
if (this.#options.decideOverride) {
|
|
193
|
+
return this.#options.decideOverride(request);
|
|
194
|
+
}
|
|
195
|
+
return callDecide(request, {
|
|
196
|
+
client: this.sdkClient,
|
|
197
|
+
callModel,
|
|
198
|
+
nativeModels: this.decisionModels,
|
|
199
|
+
spend: this.#options.spend,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The error to fail with when `step` calls a model this harness has no
|
|
204
|
+
* credentials for, else undefined. Checked before any step runs so a missing
|
|
205
|
+
* provider fails fast instead of after earlier steps' side effects. Steps the
|
|
206
|
+
* walk cannot see (dynamic branches) still hit the same error lazily at their
|
|
207
|
+
* model call.
|
|
208
|
+
*/
|
|
209
|
+
missingModelFor(step) {
|
|
210
|
+
if (this.client || this.#options.callModelOverride) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
const decideOverride = this.#options.decideOverride;
|
|
214
|
+
const needsModel = someStep(frameworkCast(step), (s) => s.kind === 'callModel' || (s.kind === 'decide' && !decideOverride));
|
|
215
|
+
return needsModel ? noLlmProviderError() : undefined;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
@@ -39,6 +39,8 @@ export declare class AgentHarnessModelCaller {
|
|
|
39
39
|
* to `step.emit` filtering.
|
|
40
40
|
*/
|
|
41
41
|
private emitItemAppended;
|
|
42
|
+
/** What the tool-round functions need from this caller. */
|
|
43
|
+
private toolRoundScope;
|
|
42
44
|
private callOverriddenModel;
|
|
43
45
|
private requireModelClient;
|
|
44
46
|
callModel(request: CallModelRequest): Promise<LLMResponse>;
|
|
@@ -51,15 +53,8 @@ export declare class AgentHarnessModelCaller {
|
|
|
51
53
|
*/
|
|
52
54
|
private applySteers;
|
|
53
55
|
private parseRoundItems;
|
|
54
|
-
/** Run the round's function calls. Returns `false` when there were none to run. */
|
|
55
|
-
private runToolRound;
|
|
56
56
|
private handleModelRecovery;
|
|
57
57
|
private handleEmptyOutputRecovery;
|
|
58
|
-
private executeToolRound;
|
|
59
|
-
private executeFunctionCall;
|
|
60
|
-
private recordSkippedToolCall;
|
|
61
|
-
/** Answer a call that never ran, so every call in the history has an output. */
|
|
62
|
-
private recordUnrunToolCall;
|
|
63
58
|
private handleToolRoundLimit;
|
|
64
59
|
}
|
|
65
60
|
export {};
|