@noetic-tools/core 5.9.0 → 5.11.0
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/in-memory-subprocess/manifest-persistence.js +5 -1
- package/dist/adapters/in-memory-subprocess/metadata.js +1 -0
- package/dist/adapters/in-memory-subprocess/types.d.ts +4 -0
- package/dist/adapters/in-memory-subprocess-adapter.js +2 -0
- package/dist/adapters/openrouter.d.ts +13 -3
- package/dist/adapters/openrouter.js +43 -12
- package/dist/builders/dynamic-workflow.js +2 -1
- package/dist/builders/provide-builder.d.ts +6 -5
- package/dist/builders/spawn-builder.d.ts +6 -2
- package/dist/builders/step-builders.d.ts +9 -2
- package/dist/builders/step-builders.js +30 -2
- package/dist/builders/workflow-hydrator.js +1 -0
- package/dist/harness/agent-harness.d.ts +7 -1
- package/dist/harness/agent-harness.js +1 -0
- package/dist/harness/deps/context.d.ts +1 -1
- package/dist/harness/deps/context.js +1 -1
- package/dist/harness/deps/types.d.ts +1 -1
- package/dist/harness/model-call.js +114 -18
- package/dist/index.d.ts +9 -5
- package/dist/index.js +1 -1
- package/dist/interpreter/action-deps.d.ts +1 -1
- package/dist/interpreter/action-deps.js +1 -1
- package/dist/interpreter/action-types.d.ts +1 -1
- package/dist/interpreter/child-span.d.ts +5 -4
- package/dist/interpreter/child-span.js +7 -5
- package/dist/interpreter/context-assembly.d.ts +5 -4
- package/dist/interpreter/context-assembly.js +18 -14
- package/dist/interpreter/execute-action.d.ts +25 -5
- package/dist/interpreter/execute-action.js +100 -18
- package/dist/interpreter/execute-control.js +7 -0
- package/dist/interpreter/execute-decide.js +2 -2
- package/dist/interpreter/execute.js +22 -8
- package/dist/interpreter/step-dispatcher.js +1 -0
- package/dist/observability/genai-attributes.d.ts +33 -3
- package/dist/observability/genai-attributes.js +34 -4
- package/dist/runtime/tool-approval.d.ts +25 -0
- package/dist/runtime/tool-approval.js +67 -0
- package/dist/unstable.d.ts +1 -1
- package/dist/util/detached-handle.d.ts +4 -10
- package/dist/util/detached-handle.js +14 -23
- package/package.json +3 -3
- package/schema/noetic-workflow.schema.json +25 -0
|
@@ -15,7 +15,9 @@ export function isStepManifest(value) {
|
|
|
15
15
|
typeof value.stepId === 'string' &&
|
|
16
16
|
typeof value.executionId === 'string' &&
|
|
17
17
|
typeof value.startedAt === 'string' &&
|
|
18
|
-
isRecord(value.overrides)
|
|
18
|
+
isRecord(value.overrides) &&
|
|
19
|
+
(value.parentExecutionId === undefined || typeof value.parentExecutionId === 'string') &&
|
|
20
|
+
(value.metadata === undefined || isRecord(value.metadata)));
|
|
19
21
|
}
|
|
20
22
|
//#endregion
|
|
21
23
|
//#region CRUD
|
|
@@ -25,8 +27,10 @@ export async function persistStepManifest(storage, request, handle) {
|
|
|
25
27
|
handleId: handle.id,
|
|
26
28
|
stepId: request.stepId,
|
|
27
29
|
executionId: request.executionId,
|
|
30
|
+
parentExecutionId: request.parentExecutionId,
|
|
28
31
|
serializedInput: request.serializedInput,
|
|
29
32
|
overrides: request.overrides,
|
|
33
|
+
metadata: request.metadata,
|
|
30
34
|
startedAt: handle.startedAt,
|
|
31
35
|
reattachMode: 'replay',
|
|
32
36
|
};
|
|
@@ -81,8 +81,12 @@ export interface InMemoryStepManifest {
|
|
|
81
81
|
handleId: string;
|
|
82
82
|
stepId: string;
|
|
83
83
|
executionId: string;
|
|
84
|
+
/** See `StepSubprocessRequest.parentExecutionId`. */
|
|
85
|
+
parentExecutionId?: string;
|
|
84
86
|
serializedInput: unknown;
|
|
85
87
|
overrides: StepSubprocessRequest['overrides'];
|
|
88
|
+
/** Caller-supplied `request.metadata` tags, restored onto rehydrated handles. */
|
|
89
|
+
metadata?: Record<string, unknown>;
|
|
86
90
|
startedAt: string;
|
|
87
91
|
reattachMode: 'replay';
|
|
88
92
|
}
|
|
@@ -113,10 +113,12 @@ export function createInMemorySubprocessAdapter(options = {}) {
|
|
|
113
113
|
startedAt: manifest.startedAt,
|
|
114
114
|
updatedAt: nowIso(),
|
|
115
115
|
metadata: {
|
|
116
|
+
...(manifest.metadata ?? {}),
|
|
116
117
|
runtime: 'in-memory',
|
|
117
118
|
kind: 'step',
|
|
118
119
|
stepId: manifest.stepId,
|
|
119
120
|
executionId: manifest.executionId,
|
|
121
|
+
parentExecutionId: manifest.parentExecutionId,
|
|
120
122
|
reattachMode: manifest.reattachMode,
|
|
121
123
|
},
|
|
122
124
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContextLayer } from '@noetic-tools/context';
|
|
2
2
|
import type { AgentHarnessContract, Context, Item, LLMResponse, StandardSchemaV1, Tool } from '@noetic-tools/types';
|
|
3
3
|
import type * as OpenRouterAgent from '@openrouter/agent';
|
|
4
|
+
import type { ApprovalOutcome } from '../runtime/tool-approval.js';
|
|
4
5
|
import type { EmbedFn } from '../types/embed.js';
|
|
5
6
|
type ProviderOutputItem = OpenRouterAgent.OpenResponsesResult['output'][number];
|
|
6
7
|
type OpenRouterInputItem = OpenRouterAgent.EasyInputMessage | OpenRouterAgent.FunctionCallItem | OpenRouterAgent.FunctionCallOutputItem | ProviderOutputItem;
|
|
@@ -64,12 +65,21 @@ export interface ExecuteToolCallParams {
|
|
|
64
65
|
/** The model's `function_call` id — keys this call's tool-UI region. */
|
|
65
66
|
callId?: string;
|
|
66
67
|
}
|
|
67
|
-
/** @internal
|
|
68
|
-
export
|
|
68
|
+
/** @internal What one model-requested tool call produced. */
|
|
69
|
+
export interface ToolCallResult {
|
|
69
70
|
output: string;
|
|
70
71
|
result?: unknown;
|
|
71
72
|
error?: boolean;
|
|
72
|
-
|
|
73
|
+
/** Set when the tool declares `needsApproval` and the call reached the approver. */
|
|
74
|
+
approval?: ApprovalOutcome;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal Execute a single tool call. Gates run in order: the
|
|
78
|
+
* `beforeToolCall` layers, input validation, then — for a tool that declares
|
|
79
|
+
* `needsApproval` — the harness approver. A refusal at any gate becomes an
|
|
80
|
+
* error tool result; the tool never runs.
|
|
81
|
+
*/
|
|
82
|
+
export declare function executeToolCall(params: ExecuteToolCallParams): Promise<ToolCallResult>;
|
|
73
83
|
/**
|
|
74
84
|
* Creates an `EmbedFn` that calls the OpenRouter embeddings API.
|
|
75
85
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { frameworkCast, isAssistantMessage, isStandardJsonSchema, isZodSchema, NoeticConfigError, SteeringAction, validateSchema, } from '@noetic-tools/types';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { askApproval } from '../runtime/tool-approval.js';
|
|
3
4
|
import { buildToolExecutionContext } from '../runtime/tool-context.js';
|
|
4
5
|
import { emitToolUi } from '../runtime/tool-ui.js';
|
|
5
6
|
const EmbeddingsResponseSchema = z.object({
|
|
@@ -293,7 +294,12 @@ function isAsyncGenerator(value) {
|
|
|
293
294
|
}
|
|
294
295
|
return Symbol.asyncIterator in value;
|
|
295
296
|
}
|
|
296
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* @internal Execute a single tool call. Gates run in order: the
|
|
299
|
+
* `beforeToolCall` layers, input validation, then — for a tool that declares
|
|
300
|
+
* `needsApproval` — the harness approver. A refusal at any gate becomes an
|
|
301
|
+
* error tool result; the tool never runs.
|
|
302
|
+
*/
|
|
297
303
|
export async function executeToolCall(params) {
|
|
298
304
|
// Model sees sanitised tool names (see `sanitizeToolNameForWire`). Match
|
|
299
305
|
// against both the original and sanitised name so internal identity (e.g.
|
|
@@ -309,17 +315,8 @@ export async function executeToolCall(params) {
|
|
|
309
315
|
}
|
|
310
316
|
if (params.layers && params.layers.length > 0) {
|
|
311
317
|
const decision = await params.harness.beforeToolCall(params.layers, params.toolName, params.args, params.context, params.callId);
|
|
312
|
-
if (decision.action
|
|
313
|
-
return
|
|
314
|
-
output: `Tool call denied: ${decision.guidance ?? 'steering rule violation'}`,
|
|
315
|
-
error: true,
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
if (decision.action === SteeringAction.Guide) {
|
|
319
|
-
return {
|
|
320
|
-
output: `Tool call redirected: ${decision.guidance}`,
|
|
321
|
-
error: true,
|
|
322
|
-
};
|
|
318
|
+
if (decision.action !== SteeringAction.Allow) {
|
|
319
|
+
return refusedResult(decision);
|
|
323
320
|
}
|
|
324
321
|
}
|
|
325
322
|
const validated = await validateSchema(matchedTool.input, params.args);
|
|
@@ -330,6 +327,40 @@ export async function executeToolCall(params) {
|
|
|
330
327
|
};
|
|
331
328
|
}
|
|
332
329
|
const parsedArgs = validated.value;
|
|
330
|
+
const approval = matchedTool.needsApproval
|
|
331
|
+
? await askApproval({
|
|
332
|
+
harness: params.harness,
|
|
333
|
+
toolName: matchedTool.name,
|
|
334
|
+
toolArgs: parsedArgs,
|
|
335
|
+
callId: params.callId,
|
|
336
|
+
ctx: params.context,
|
|
337
|
+
})
|
|
338
|
+
: undefined;
|
|
339
|
+
if (approval && approval.decision.action !== SteeringAction.Allow) {
|
|
340
|
+
return {
|
|
341
|
+
...refusedResult(approval.decision),
|
|
342
|
+
approval: approval.outcome,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
const executed = await runMatchedTool(params, matchedTool, parsedArgs);
|
|
346
|
+
return {
|
|
347
|
+
...executed,
|
|
348
|
+
approval: approval?.outcome,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function refusedResult(decision) {
|
|
352
|
+
if (decision.action === SteeringAction.Guide) {
|
|
353
|
+
return {
|
|
354
|
+
output: `Tool call redirected: ${decision.guidance}`,
|
|
355
|
+
error: true,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
output: `Tool call denied: ${decision.guidance ?? 'steering rule violation'}`,
|
|
360
|
+
error: true,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
async function runMatchedTool(params, matchedTool, parsedArgs) {
|
|
333
364
|
const toolCtx = buildToolExecutionContext(params.context, params.harness);
|
|
334
365
|
const callId = params.callId;
|
|
335
366
|
const uiBase = callId !== undefined
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Pattern that lets an LLM generate a workflow as JSON during execution,
|
|
3
3
|
* then hydrates and runs it within the same harness session.
|
|
4
4
|
*/
|
|
5
|
+
import { exportSpans } from '@noetic-tools/context';
|
|
5
6
|
import { frameworkCast, NoeticConfigError } from '@noetic-tools/types';
|
|
6
7
|
import { NoeticAttr } from '../observability/genai-attributes.js';
|
|
7
8
|
import { WorkflowDocumentSchema, workflowDepth, workflowGraph } from '../schemas/workflow.js';
|
|
@@ -161,7 +162,7 @@ export async function parseAndRunWorkflow(opts) {
|
|
|
161
162
|
}
|
|
162
163
|
finally {
|
|
163
164
|
runSpan.end();
|
|
164
|
-
await opts.harness.traceExporter
|
|
165
|
+
await exportSpans(opts.harness.traceExporter, [
|
|
165
166
|
runSpan,
|
|
166
167
|
]);
|
|
167
168
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ContextConfig, ContextData, ContextLayer } from '@noetic-tools/context';
|
|
2
2
|
import type { Step, StepReplay, StepWithContext } from '@noetic-tools/types';
|
|
3
|
+
export interface WithContextOpts<TContext, I, O> extends StepReplay<TContext, I> {
|
|
4
|
+
id: string;
|
|
5
|
+
child: Step<TContext, I, O>;
|
|
6
|
+
context: ContextConfig | ContextLayer[];
|
|
7
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* Creates a provide step that attaches context layers to its child without creating an isolated context.
|
|
5
10
|
* Like React's Context.Provider — layers are available to all descendant steps.
|
|
@@ -14,8 +19,4 @@ import type { Step, StepReplay, StepWithContext } from '@noetic-tools/types';
|
|
|
14
19
|
* @throws `NoeticConfigError` with code `MISSING_CHILD_STEP` if `child` is not provided.
|
|
15
20
|
* @throws `NoeticConfigError` with code `MISSING_CONTEXT_LAYERS` if `context` is not provided.
|
|
16
21
|
*/
|
|
17
|
-
export declare function withContext<TContext = ContextData, I = unknown, O = unknown>(opts:
|
|
18
|
-
id: string;
|
|
19
|
-
child: Step<TContext, I, O>;
|
|
20
|
-
context: ContextConfig | ContextLayer[];
|
|
21
|
-
} & StepReplay<TContext, I>): StepWithContext<TContext, I, O>;
|
|
22
|
+
export declare function withContext<TContext = ContextData, I = unknown, O = unknown>(opts: WithContextOpts<TContext, I, O>): StepWithContext<TContext, I, O>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ContextConfig, ContextData, ContextLayer } from '@noetic-tools/context';
|
|
2
2
|
import type { Step, StepReplay, StepSpawn, SubprocessAdapter } from '@noetic-tools/types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link spawn}.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface SpawnOpts<TContext = ContextData, I = unknown, O = unknown> extends StepReplay<TContext, I> {
|
|
4
9
|
id: string;
|
|
5
10
|
child: Step<TContext, I, O>;
|
|
6
11
|
context?: ContextConfig | ContextLayer[];
|
|
@@ -28,4 +33,3 @@ interface SpawnOpts<TContext, I, O> extends StepReplay<TContext, I> {
|
|
|
28
33
|
* @throws `NoeticConfigError` with code `MISSING_CHILD_STEP` if `child` is not provided.
|
|
29
34
|
*/
|
|
30
35
|
export declare function spawn<TContext = ContextData, I = unknown, O = unknown>(opts: SpawnOpts<TContext, I, O>): StepSpawn<TContext, I, O>;
|
|
31
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextData } from '@noetic-tools/context';
|
|
2
|
-
import type { AcpAgent, AcpClientCapabilityConfig, AcpContentBlock, AcpMcpServer, AcpPermissionHandler, AcpPermissionPolicy, AcpSessionPolicy, Context, Lazy, ModelParams, OutputCodec, RetryPolicy, ServerToolSpec, StandardSchemaV1, StepAcpAgent, StepCallModel, StepInvokeTool, StepReplay, StepRunCode, SubprocessAdapter, Tool } from '@noetic-tools/types';
|
|
2
|
+
import type { AcpAgent, AcpClientCapabilityConfig, AcpContentBlock, AcpMcpServer, AcpPermissionHandler, AcpPermissionPolicy, AcpSessionPolicy, Context, Lazy, ModelParams, OutputCodec, RetryPolicy, ServerToolSpec, StandardSchemaV1, StepAcpAgent, StepCallModel, StepInvokeTool, StepReplay, StepRunCode, SubprocessAdapter, Tool, ToolChoice } from '@noetic-tools/types';
|
|
3
3
|
export interface RunCodeOpts<TContext, I, O> extends StepReplay<TContext, I> {
|
|
4
4
|
id: string;
|
|
5
5
|
execute: (input: I, ctx: Context<TContext>) => Promise<O>;
|
|
@@ -23,6 +23,11 @@ export interface CallModelOpts<TContext, O, I = unknown> extends StepReplay<TCon
|
|
|
23
23
|
* server tool the provider executes, e.g. web search/fetch).
|
|
24
24
|
*/
|
|
25
25
|
tools?: Lazy<(Tool | ServerToolSpec)[] | undefined, TContext>;
|
|
26
|
+
/**
|
|
27
|
+
* How the model may use its tools: `'auto'` (default), `'required'`,
|
|
28
|
+
* `'none'`, or `{ tool: name }` to force one client tool from `tools`.
|
|
29
|
+
*/
|
|
30
|
+
toolChoice?: ToolChoice;
|
|
26
31
|
/** Structured output: a Standard Schema (Zod, Valibot, …) or a streaming `OutputCodec` (e.g. OpenUI Lang). */
|
|
27
32
|
output?: StandardSchemaV1<unknown, O> | OutputCodec<O>;
|
|
28
33
|
/**
|
|
@@ -94,11 +99,13 @@ export declare function runCode<TContext = ContextData, I = unknown, O = unknown
|
|
|
94
99
|
* @param opts.instructions - Optional system prompt; eager string or `(ctx) => string | undefined` getter.
|
|
95
100
|
* @param opts.tools - Optional tools; eager array or `(ctx) => Tool[] | undefined` getter.
|
|
96
101
|
* @param opts.output - Optional Zod schema enabling structured output parsing.
|
|
97
|
-
* @param opts.
|
|
102
|
+
* @param opts.toolChoice - Optional tool choice: `'auto'` (default), `'required'`, `'none'`, or `{ tool: name }`.
|
|
103
|
+
* @param opts.params - Optional model parameters (temperature, topP, maxTokens, serviceTier).
|
|
98
104
|
* @returns A `StepCallModel` that can be composed into larger pipelines. The step
|
|
99
105
|
* is auto-registered in the shared step registry.
|
|
100
106
|
* @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
|
|
101
107
|
* @throws `NoeticConfigError` with code `MISSING_MODEL` if an eager `model` string is empty. Function-form models are validated at step execution.
|
|
108
|
+
* @throws `NoeticConfigError` with code `UNKNOWN_TOOL_CHOICE` if `toolChoice` forces a tool missing from an eager `tools` array.
|
|
102
109
|
*/
|
|
103
110
|
export declare function callModel<TContext = ContextData, I = unknown, O = unknown>(opts: CallModelOpts<TContext, O, I>): StepCallModel<TContext, I, O>;
|
|
104
111
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoeticConfigError } from '@noetic-tools/types';
|
|
1
|
+
import { isServerToolSpec, NoeticConfigError } from '@noetic-tools/types';
|
|
2
2
|
import { getDefaultRegistrar } from '../types/step-registrar.js';
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region ACP agent builder helper
|
|
@@ -31,6 +31,31 @@ function validateAcpAgentOpts(opts) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* A forced tool must be one the step offers. Only an eager `tools` array can be
|
|
36
|
+
* checked here; a getter's tools are checked when the request is built.
|
|
37
|
+
*/
|
|
38
|
+
function validateToolChoice(opts) {
|
|
39
|
+
const choice = opts.toolChoice;
|
|
40
|
+
if (typeof choice !== 'object' || !Array.isArray(opts.tools)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const names = opts.tools.flatMap((entry) => isServerToolSpec(entry)
|
|
44
|
+
? []
|
|
45
|
+
: [
|
|
46
|
+
entry.name,
|
|
47
|
+
]);
|
|
48
|
+
if (names.includes(choice.tool)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
throw new NoeticConfigError({
|
|
52
|
+
code: 'UNKNOWN_TOOL_CHOICE',
|
|
53
|
+
message: `callModel(${JSON.stringify(opts.id)}) forces tool ${JSON.stringify(choice.tool)}, which is not in its tools.`,
|
|
54
|
+
hint: names.length > 0
|
|
55
|
+
? `Force one of the step's tools (${names.join(', ')}), or add '${choice.tool}' to \`tools\`.`
|
|
56
|
+
: `Add '${choice.tool}' to \`tools\`, or drop \`toolChoice\`.`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
34
59
|
//#endregion
|
|
35
60
|
//#region Builders
|
|
36
61
|
/**
|
|
@@ -78,11 +103,13 @@ export function runCode(opts) {
|
|
|
78
103
|
* @param opts.instructions - Optional system prompt; eager string or `(ctx) => string | undefined` getter.
|
|
79
104
|
* @param opts.tools - Optional tools; eager array or `(ctx) => Tool[] | undefined` getter.
|
|
80
105
|
* @param opts.output - Optional Zod schema enabling structured output parsing.
|
|
81
|
-
* @param opts.
|
|
106
|
+
* @param opts.toolChoice - Optional tool choice: `'auto'` (default), `'required'`, `'none'`, or `{ tool: name }`.
|
|
107
|
+
* @param opts.params - Optional model parameters (temperature, topP, maxTokens, serviceTier).
|
|
82
108
|
* @returns A `StepCallModel` that can be composed into larger pipelines. The step
|
|
83
109
|
* is auto-registered in the shared step registry.
|
|
84
110
|
* @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
|
|
85
111
|
* @throws `NoeticConfigError` with code `MISSING_MODEL` if an eager `model` string is empty. Function-form models are validated at step execution.
|
|
112
|
+
* @throws `NoeticConfigError` with code `UNKNOWN_TOOL_CHOICE` if `toolChoice` forces a tool missing from an eager `tools` array.
|
|
86
113
|
*/
|
|
87
114
|
export function callModel(opts) {
|
|
88
115
|
if (!opts.id || opts.id.trim() === '') {
|
|
@@ -102,6 +129,7 @@ export function callModel(opts) {
|
|
|
102
129
|
hint: "Pass a model identifier, e.g. model: 'anthropic/claude-sonnet-4-20250514'.",
|
|
103
130
|
});
|
|
104
131
|
}
|
|
132
|
+
validateToolChoice(opts);
|
|
105
133
|
const built = {
|
|
106
134
|
kind: 'callModel',
|
|
107
135
|
...opts,
|
|
@@ -88,6 +88,7 @@ function hydrateCallModelNode(node, ctx) {
|
|
|
88
88
|
model: node.model ?? 'openai/gpt-4o',
|
|
89
89
|
instructions: node.instructions,
|
|
90
90
|
tools: combined.length > 0 ? combined : undefined,
|
|
91
|
+
toolChoice: node.toolChoice,
|
|
91
92
|
params: node.params,
|
|
92
93
|
output: resolveOutputCodec(node.output, node.id, ctx),
|
|
93
94
|
});
|
|
@@ -4,7 +4,7 @@ import type { LayerStateStore, RecallCache } from './deps/context.js';
|
|
|
4
4
|
import type { DetachedSpawnOverrides } from './deps/interpreter.js';
|
|
5
5
|
import type { CheckpointStore, EventBroadcaster, RestoreCheckpointOptions, StepLedgerRetention, StepLedgerStore } from './deps/runtime.js';
|
|
6
6
|
import { ChannelStore } from './deps/runtime.js';
|
|
7
|
-
import type { AcpLiveSession, AcpSessionInfo, AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, Channel, ChannelHandle, Context, ContextCacheConfig, ContextCacheStore, ContextData, ContextLayer, CwdState, DecideRequest, DecideResponse, DecisionRecord, DeliveryMode, DetachedHandle, ExecuteInput, ExecuteOptions, ExternalChannel, FsAdapter, HarnessResponse, HarnessStatus, Item, ItemSchemaConfig, LLMResponse, LlmProviderConfig, ProjectionPolicy, RecallLayerOutput, RecallOptions, SessionScope, SessionUsage, ShellAdapter, Span, SteeringDecision, Step, StorageAdapter, StreamEvent, StreamingItem, SubprocessAdapter, Tool, TraceExporter, ZodType } from './deps/types.js';
|
|
7
|
+
import type { AcpLiveSession, AcpSessionInfo, AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, Channel, ChannelHandle, Context, ContextCacheConfig, ContextCacheStore, ContextData, ContextLayer, CwdState, DecideRequest, DecideResponse, DecisionRecord, DeliveryMode, DetachedHandle, ExecuteInput, ExecuteOptions, ExternalChannel, FsAdapter, HarnessResponse, HarnessStatus, Item, ItemSchemaConfig, LLMResponse, LlmProviderConfig, ProjectionPolicy, RecallLayerOutput, RecallOptions, SessionScope, SessionUsage, ShellAdapter, Span, SteeringDecision, Step, StorageAdapter, StreamEvent, StreamingItem, SubprocessAdapter, Tool, ToolApprover, TraceExporter, ZodType } from './deps/types.js';
|
|
8
8
|
export { createStreamIdleWatchdog } from './model-call.js';
|
|
9
9
|
/**
|
|
10
10
|
* Storage-scoped environment configuration for `AgentHarness`.
|
|
@@ -90,6 +90,12 @@ interface AgentHarnessOpts<TParams extends Record<string, unknown> = Record<stri
|
|
|
90
90
|
initialCwd?: string;
|
|
91
91
|
/** Default model for `decide` steps. */
|
|
92
92
|
decisionModel?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Approves or refuses calls to tools that declare `needsApproval`, after the
|
|
95
|
+
* `beforeToolCall` layers allow them. Without one, those calls run
|
|
96
|
+
* unapproved and the harness warns once per tool name.
|
|
97
|
+
*/
|
|
98
|
+
approveToolCall?: ToolApprover;
|
|
93
99
|
/** @internal Test-only escape hatch to inject a mock callModel implementation. */
|
|
94
100
|
_testCallModel?: (request: CallModelRequest) => Promise<LLMResponse>;
|
|
95
101
|
/** @internal Test-only escape hatch to inject a mock decide implementation. */
|
|
@@ -306,6 +306,7 @@ export class AgentHarness {
|
|
|
306
306
|
forceAtomicRecall: opts.forceAtomicRecall,
|
|
307
307
|
contextCache: opts.contextCache,
|
|
308
308
|
decisionModel: opts.decisionModel,
|
|
309
|
+
approveToolCall: opts.approveToolCall,
|
|
309
310
|
};
|
|
310
311
|
this.fs = environment?.fs ?? createInMemoryFsAdapter();
|
|
311
312
|
this.shell = environment?.shell ?? createInMemoryShellAdapter();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { LayerStateStore, RecallCache } from '@noetic-tools/context';
|
|
2
|
-
export { afterModelCallLayers, allocateBudgets, assembleView, beforeToolCallLayers, completeLayers, contextToExecCtx, createContextCacheStore, createLayerStateStore, createRecallCache, DEFAULT_PROJECTION, disposeLayers, executeRerender, initLayers, notifyDecision, projectHistoryLayers, recallLayers, recallLayersAtomic, recallLayersEventual, resolveLayerTools, runAppendPipeline, storeLayers, } from '@noetic-tools/context';
|
|
2
|
+
export { afterModelCallLayers, allocateBudgets, assembleView, beforeToolCallLayers, completeLayers, contextToExecCtx, createContextCacheStore, createLayerStateStore, createRecallCache, DEFAULT_PROJECTION, disposeLayers, executeRerender, exportSpans, initLayers, notifyDecision, projectHistoryLayers, recallLayers, recallLayersAtomic, recallLayersEventual, resolveLayerTools, runAppendPipeline, storeLayers, } from '@noetic-tools/context';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { afterModelCallLayers, allocateBudgets, assembleView, beforeToolCallLayers, completeLayers, contextToExecCtx, createContextCacheStore, createLayerStateStore, createRecallCache, DEFAULT_PROJECTION, disposeLayers, executeRerender, initLayers, notifyDecision, projectHistoryLayers, recallLayers, recallLayersAtomic, recallLayersEventual, resolveLayerTools, runAppendPipeline, storeLayers, } from '@noetic-tools/context';
|
|
1
|
+
export { afterModelCallLayers, allocateBudgets, assembleView, beforeToolCallLayers, completeLayers, contextToExecCtx, createContextCacheStore, createLayerStateStore, createRecallCache, DEFAULT_PROJECTION, disposeLayers, executeRerender, exportSpans, initLayers, notifyDecision, projectHistoryLayers, recallLayers, recallLayersAtomic, recallLayersEventual, resolveLayerTools, runAppendPipeline, storeLayers, } from '@noetic-tools/context';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { ContextCacheConfig, ContextCacheStore, ContextData, ContextLayer, ExecutionContext, ProjectionPolicy, StorageAdapter, } from '@noetic-tools/context';
|
|
2
|
-
export type { AcpKeepAlive, AcpLiveSession, AcpSessionInfo, AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, Channel, ChannelHandle, Context, CwdState, DecideRequest, DecideResponse, DecisionRecord, DeliveryMode, DetachedHandle, ExecuteInput, ExecuteOptions, ExternalChannel, FsAdapter, HarnessResponse, HarnessStatus, Item, ItemSchemaConfig, ItemSchemaExtensions, LLMResponse, LlmProviderConfig, RecallLayerOutput, RecallOptions, SessionScope, SessionUsage, ShellAdapter, Span, SteeringDecision, Step, StreamEvent, StreamingItem, SubprocessAdapter, Tool, TraceExporter, } from '@noetic-tools/types';
|
|
2
|
+
export type { AcpKeepAlive, AcpLiveSession, AcpSessionInfo, AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, Channel, ChannelHandle, Context, CwdState, DecideRequest, DecideResponse, DecisionRecord, DeliveryMode, DetachedHandle, ExecuteInput, ExecuteOptions, ExternalChannel, FsAdapter, HarnessResponse, HarnessStatus, Item, ItemSchemaConfig, ItemSchemaExtensions, LLMResponse, LlmProviderConfig, RecallLayerOutput, RecallOptions, SessionScope, SessionUsage, ShellAdapter, Span, SteeringDecision, Step, StreamEvent, StreamingItem, SubprocessAdapter, Tool, ToolApprover, TraceExporter, } from '@noetic-tools/types';
|
|
3
3
|
export { SteeringAction } from '@noetic-tools/types';
|
|
4
4
|
export type { ZodType } from 'zod';
|