operon-agents-core 0.1.0-alpha.34 → 0.1.0-alpha.35

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.
@@ -51,6 +51,8 @@ export interface BuildAgentOptions {
51
51
  * Only invoked when a `tools` registry was provided. Default: silent (unchanged behavior).
52
52
  */
53
53
  readonly onUnknownTool?: (toolName: string) => void;
54
+ /** Tools the agent gets on top of the ones the profile picks. A name the profile already uses throws. */
55
+ readonly extraTools?: readonly Tool[];
54
56
  /** Force the built agent's model, overriding the profile's `model`. Omit to keep the profile's ref
55
57
  * (or inherit the session model when the profile declares none). */
56
58
  readonly model?: string | ChatModel;
@@ -148,6 +148,12 @@ export async function buildAgentFromProfile(profile, options = {}) {
148
148
  else if (options.tools !== undefined)
149
149
  options.onUnknownTool?.(name);
150
150
  }
151
+ for (const tool of options.extraTools ?? []) {
152
+ if (toolset.some((own) => own.schema.name === tool.schema.name)) {
153
+ throw new Error(`extra tool "${tool.schema.name}" has the name of a tool the "${profile.name}" profile already uses`);
154
+ }
155
+ toolset.push(tool);
156
+ }
151
157
  const model = options.model ??
152
158
  (profile.model !== undefined && options.resolveModel !== undefined ? await options.resolveModel(profile.model) : undefined);
153
159
  const roleAdditional = options.roleAdditional;
@@ -61,6 +61,12 @@ export interface RunnerConfig<TContext = unknown> {
61
61
  * `Agent` tool is untouched — only `Workflow` is withheld.
62
62
  */
63
63
  readonly workflowTool?: boolean;
64
+ /**
65
+ * Tools no run offers, by name, wherever they come from (the agent's own, a capability's, an MCP
66
+ * server's, `Agent`/`Workflow`). Left out of the request and of what a program can call, so a
67
+ * call to one fails as an unknown tool. Subagents inherit it.
68
+ */
69
+ readonly disabledTools?: readonly string[];
64
70
  }
65
71
  export type AgentInput = string | Message[];
66
72
  /**
@@ -141,6 +147,8 @@ export interface RunOptions<TContext = unknown> {
141
147
  readonly maxConcurrentSubagents?: number;
142
148
  /** Replaces `RunnerConfig.workflowTool` for this run. */
143
149
  readonly workflowTool?: boolean;
150
+ /** Replaces `RunnerConfig.disabledTools` for this run. */
151
+ readonly disabledTools?: readonly string[];
144
152
  }
145
153
  /**
146
154
  * A run's runtime: the shared environment (session/store/environment/permission/…, one per
@@ -171,6 +179,8 @@ export interface RunState<TContext> {
171
179
  readonly maxConcurrentSubagents?: number;
172
180
  /** False when the host withholds the builtin `Workflow` tool (see RunnerConfig). */
173
181
  readonly workflowTool?: boolean;
182
+ /** Tools this run never offers (see RunnerConfig). */
183
+ readonly disabledTools?: readonly string[];
174
184
  readonly permission: PermissionManager;
175
185
  readonly capabilities: AssembledCapabilities;
176
186
  readonly steer: SteerBus;
@@ -533,6 +533,7 @@ export class Runner {
533
533
  subagentProvider: opts?.subagentProvider === null ? undefined : opts?.subagentProvider ?? this.config.subagentProvider,
534
534
  ...(maxConcurrentSubagents !== undefined ? { maxConcurrentSubagents } : {}),
535
535
  workflowTool: opts?.workflowTool ?? this.config.workflowTool,
536
+ disabledTools: opts?.disabledTools ?? this.config.disabledTools,
536
537
  permission,
537
538
  capabilities,
538
539
  steer: session.steer,
@@ -9,7 +9,9 @@ export async function buildRunTools(active, state, runAgent, model) {
9
9
  // Capability (MCP) tools are the deferred-loading candidates. When the agent
10
10
  // opts in, they stay executable but are omitted from the model-facing schema
11
11
  // projection until a SearchTool result adds their names to the transcript.
12
- const rawCapTools = await state.capabilities.listTools();
12
+ // A disabled tool is not even a deferred-loading candidate: SearchTool must not turn it up.
13
+ const disabled = new Set(state.disabledTools ?? []);
14
+ const rawCapTools = (await state.capabilities.listTools()).filter((tool) => !disabled.has(tool.schema.name));
13
15
  // A tagged (dynamically contributed) tool loses a name clash and says so; untagged tools are
14
16
  // trusted contributors and keep theirs. Between two tagged claimants the first one survives,
15
17
  // so a clash never makes the name vanish entirely. See `tagToolSource`.
@@ -59,17 +61,21 @@ export async function buildRunTools(active, state, runAgent, model) {
59
61
  return finish(state, tools, deferredToolNames, deferEnabled);
60
62
  }
61
63
  /**
62
- * Last stop before the turn: let capabilities narrow the complete registry (the extension
63
- * runtime's `setActiveTools` rides this). Filtering happens AFTER assembly so a filter sees
64
- * handoff and subagent tools too, and the deferred-name set is pruned to whatever survived.
64
+ * Last stop before the turn: drop the run's disabled tools, then let capabilities narrow the
65
+ * complete registry (the extension runtime's `setActiveTools` rides this). Filtering happens AFTER
66
+ * assembly so it sees handoff and subagent tools too, and the deferred-name set is pruned to
67
+ * whatever survived. What is dropped here is gone for the turn: not in the request, not in what a
68
+ * program can call, not executable.
65
69
  */
66
- function finish(state, tools, deferredToolNames, deferEnabled) {
70
+ function finish(state, assembled, deferredToolNames, deferEnabled) {
71
+ const disabled = state.disabledTools?.length ? new Set(state.disabledTools) : undefined;
72
+ const tools = disabled ? assembled.filter((tool) => !disabled.has(tool.schema.name)) : assembled;
67
73
  const filtered = state.capabilities.applyToolFilters(tools, {
68
74
  address: state.address,
69
75
  isRootAgent: state.address === DEFAULT_ADDRESS,
70
76
  });
71
77
  const enabled = deferEnabled && filtered.some((tool) => tool.schema.name === "SearchTool");
72
- if (filtered === tools)
78
+ if (filtered === assembled)
73
79
  return { tools, deferredToolNames, deferEnabled: enabled };
74
80
  const surviving = new Set(filtered.map((tool) => tool.schema.name));
75
81
  return {
@@ -23,6 +23,7 @@ function mergeOne(base, layer) {
23
23
  model: layer.model ?? base.model,
24
24
  agent: layer.agent ?? base.agent,
25
25
  tools: layer.tools ?? base.tools,
26
+ disabledTools: layer.disabledTools ?? base.disabledTools,
26
27
  appendSystemPrompt: layer.appendSystemPrompt ?? base.appendSystemPrompt,
27
28
  extensions: layer.extensions !== undefined || base.extensions !== undefined ? { ...base.extensions, ...layer.extensions } : undefined,
28
29
  skills: layer.skills ?? base.skills,
@@ -232,6 +232,7 @@ export declare const AgentFrameworkConfigSchema: z.ZodObject<{
232
232
  model: z.ZodOptional<z.ZodString>;
233
233
  agent: z.ZodOptional<z.ZodString>;
234
234
  tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
235
+ disabledTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
235
236
  appendSystemPrompt: z.ZodOptional<z.ZodString>;
236
237
  extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
237
238
  skills: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
@@ -173,6 +173,8 @@ export const AgentFrameworkConfigSchema = z.object({
173
173
  agent: z.string().min(1).optional(),
174
174
  /** Names of the registered tools the default agent may draw on by default (see `SessionConfig.tools`). */
175
175
  tools: z.array(z.string().min(1)).optional(),
176
+ /** Tools sessions never offer by default (see `SessionConfig.disabledTools`). */
177
+ disabledTools: z.array(z.string().min(1)).optional(),
176
178
  appendSystemPrompt: z.string().optional(),
177
179
  /** Per-extension session parameters by extension id; `false` skips that extension. */
178
180
  extensions: z.record(z.string(), z.unknown()).optional(),
@@ -148,6 +148,7 @@ export declare const SessionConfigSchema: z.ZodObject<{
148
148
  thinking: z.ZodOptional<z.ZodString>;
149
149
  agent: z.ZodOptional<z.ZodString>;
150
150
  tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ disabledTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
152
  appendSystemPrompt: z.ZodOptional<z.ZodString>;
152
153
  mcp: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
153
154
  servers: z.ZodRecord<z.ZodString, z.ZodPreprocess<z.ZodPipe<z.ZodObject<{
@@ -308,7 +309,7 @@ export interface HarnessConfig {
308
309
  export declare function parseSessionConfig(input: unknown, where?: string): SessionConfig;
309
310
  /**
310
311
  * The configuration a session runs on: `explicit` over `defaults`. A field the session gives wins
311
- * whole — collections (`tools`, `hooks`, `mcp.servers`, `permission.rules`) are replaced, never
312
+ * whole — collections (`tools`, `disabledTools`, `hooks`, `mcp.servers`, `permission.rules`) are replaced, never
312
313
  * concatenated. Three sections are settings rather than collections and are overridden one key at a
313
314
  * time: `permission` (`mode` and `rules` separately), `limits`, and `extensions` (per extension id).
314
315
  */
@@ -54,6 +54,11 @@ export const SessionConfigSchema = z.strictObject({
54
54
  * uses by name and those names resolve against this set, so naming fewer narrows the agent; a
55
55
  * tool the profile does not list is not added by naming it here. */
56
56
  tools: z.array(z.string().min(1)).optional(),
57
+ /** Tools this session never offers, by name, wherever they come from: built-in, a capability's
58
+ * (`CronCreate`, `Skill`…), an MCP server's (`mcp__server__tool`), `Agent`/`Workflow`. A disabled
59
+ * tool is left out of every request and cannot be called, from a program either; the permission
60
+ * mode does not bring it back. Applies to the session's subagents too. */
61
+ disabledTools: z.array(z.string().min(1)).optional(),
57
62
  appendSystemPrompt: z.string().optional(),
58
63
  mcp: SessionMcpConfigSchema.optional(),
59
64
  skills: SkillsConfigSchema.optional(),
@@ -84,7 +89,7 @@ function keyed(base, over) {
84
89
  }
85
90
  /**
86
91
  * The configuration a session runs on: `explicit` over `defaults`. A field the session gives wins
87
- * whole — collections (`tools`, `hooks`, `mcp.servers`, `permission.rules`) are replaced, never
92
+ * whole — collections (`tools`, `disabledTools`, `hooks`, `mcp.servers`, `permission.rules`) are replaced, never
88
93
  * concatenated. Three sections are settings rather than collections and are overridden one key at a
89
94
  * time: `permission` (`mode` and `rules` separately), `limits`, and `extensions` (per extension id).
90
95
  */
@@ -178,6 +183,7 @@ export function normalizeHarnessConfig(raw) {
178
183
  model: file.model,
179
184
  agent: file.agent,
180
185
  tools: file.tools,
186
+ disabledTools: file.disabledTools,
181
187
  appendSystemPrompt: file.appendSystemPrompt,
182
188
  thinking: thinkingLevelOf(file.thinking),
183
189
  mcp: Object.keys(file.mcpServers).length > 0 ? { servers: file.mcpServers } : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "operon-agents-core",
3
- "version": "0.1.0-alpha.34",
3
+ "version": "0.1.0-alpha.35",
4
4
  "description": "Internal engine for operon-agents. Prefer operon-agents for application code.",
5
5
  "type": "module",
6
6
  "engines": {