@framers/agentos 0.1.97 → 0.1.99
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 +58 -13
- package/dist/api/agency.d.ts +51 -0
- package/dist/api/agency.d.ts.map +1 -0
- package/dist/api/agency.js +645 -0
- package/dist/api/agency.js.map +1 -0
- package/dist/api/agent.d.ts +15 -54
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +14 -7
- package/dist/api/agent.js.map +1 -1
- package/dist/api/generateText.d.ts +16 -0
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js.map +1 -1
- package/dist/api/hitl.d.ts +139 -0
- package/dist/api/hitl.d.ts.map +1 -0
- package/dist/api/hitl.js +211 -0
- package/dist/api/hitl.js.map +1 -0
- package/dist/api/strategies/debate.d.ts +16 -0
- package/dist/api/strategies/debate.d.ts.map +1 -0
- package/dist/api/strategies/debate.js +118 -0
- package/dist/api/strategies/debate.js.map +1 -0
- package/dist/api/strategies/hierarchical.d.ts +20 -0
- package/dist/api/strategies/hierarchical.d.ts.map +1 -0
- package/dist/api/strategies/hierarchical.js +140 -0
- package/dist/api/strategies/hierarchical.js.map +1 -0
- package/dist/api/strategies/index.d.ts +41 -0
- package/dist/api/strategies/index.d.ts.map +1 -0
- package/dist/api/strategies/index.js +95 -0
- package/dist/api/strategies/index.js.map +1 -0
- package/dist/api/strategies/parallel.d.ts +17 -0
- package/dist/api/strategies/parallel.d.ts.map +1 -0
- package/dist/api/strategies/parallel.js +122 -0
- package/dist/api/strategies/parallel.js.map +1 -0
- package/dist/api/strategies/review-loop.d.ts +18 -0
- package/dist/api/strategies/review-loop.d.ts.map +1 -0
- package/dist/api/strategies/review-loop.js +153 -0
- package/dist/api/strategies/review-loop.js.map +1 -0
- package/dist/api/strategies/sequential.d.ts +15 -0
- package/dist/api/strategies/sequential.d.ts.map +1 -0
- package/dist/api/strategies/sequential.js +94 -0
- package/dist/api/strategies/sequential.js.map +1 -0
- package/dist/api/strategies/shared.d.ts +36 -0
- package/dist/api/strategies/shared.d.ts.map +1 -0
- package/dist/api/strategies/shared.js +82 -0
- package/dist/api/strategies/shared.js.map +1 -0
- package/dist/api/types.d.ts +806 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +25 -0
- package/dist/api/types.js.map +1 -0
- package/dist/discovery/CapabilityDiscoveryEngine.d.ts +7 -0
- package/dist/discovery/CapabilityDiscoveryEngine.d.ts.map +1 -1
- package/dist/discovery/CapabilityDiscoveryEngine.js +21 -0
- package/dist/discovery/CapabilityDiscoveryEngine.js.map +1 -1
- package/dist/discovery/types.d.ts +2 -0
- package/dist/discovery/types.d.ts.map +1 -1
- package/dist/emergent/EmergentCapabilityEngine.d.ts +16 -0
- package/dist/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/emergent/EmergentCapabilityEngine.js +51 -0
- package/dist/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/emergent/EmergentToolRegistry.d.ts +8 -0
- package/dist/emergent/EmergentToolRegistry.d.ts.map +1 -1
- package/dist/emergent/EmergentToolRegistry.js +42 -1
- package/dist/emergent/EmergentToolRegistry.js.map +1 -1
- package/dist/emergent/ToolPackage.d.ts +57 -0
- package/dist/emergent/ToolPackage.d.ts.map +1 -0
- package/dist/emergent/ToolPackage.js +145 -0
- package/dist/emergent/ToolPackage.js.map +1 -0
- package/dist/emergent/index.d.ts +2 -0
- package/dist/emergent/index.d.ts.map +1 -1
- package/dist/emergent/index.js +1 -0
- package/dist/emergent/index.js.map +1 -1
- package/dist/emergent/types.d.ts +27 -0
- package/dist/emergent/types.d.ts.map +1 -1
- package/dist/emergent/types.js +2 -0
- package/dist/emergent/types.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agency.ts
|
|
3
|
+
* Multi-agent agency factory for the AgentOS high-level API.
|
|
4
|
+
*
|
|
5
|
+
* `agency()` accepts an {@link AgencyOptions} configuration, compiles the
|
|
6
|
+
* requested orchestration strategy, wires resource controls, and returns a
|
|
7
|
+
* single {@link Agent}-compatible interface that coordinates all sub-agents.
|
|
8
|
+
*
|
|
9
|
+
* The returned instance exposes `generate`, `stream`, `session`, `usage`, and
|
|
10
|
+
* `close` — identical surface to a single `agent()` instance — so callers can
|
|
11
|
+
* swap between them transparently.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { agency, hitl } from '@framers/agentos';
|
|
16
|
+
*
|
|
17
|
+
* const myAgency = agency({
|
|
18
|
+
* model: 'openai:gpt-4o',
|
|
19
|
+
* strategy: 'sequential',
|
|
20
|
+
* agents: {
|
|
21
|
+
* researcher: { instructions: 'Find relevant information.' },
|
|
22
|
+
* writer: { instructions: 'Write a clear summary.' },
|
|
23
|
+
* },
|
|
24
|
+
* controls: { maxTotalTokens: 50_000, onLimitReached: 'warn' },
|
|
25
|
+
* hitl: { approvals: { beforeTool: ['delete'] }, handler: hitl.autoApprove() },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const result = await myAgency.generate('Summarise recent AI research.');
|
|
29
|
+
* console.log(result.text);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { compileStrategy, isAgent } from './strategies/index.js';
|
|
33
|
+
import { AgencyConfigError } from './types.js';
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Public factory
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
/**
|
|
38
|
+
* Creates a multi-agent agency that coordinates a named roster of sub-agents
|
|
39
|
+
* using the specified orchestration strategy.
|
|
40
|
+
*
|
|
41
|
+
* The agency validates configuration immediately and throws an
|
|
42
|
+
* {@link AgencyConfigError} on any structural problem so issues surface at
|
|
43
|
+
* wiring time rather than the first call.
|
|
44
|
+
*
|
|
45
|
+
* @param opts - Full agency configuration including the `agents` roster, optional
|
|
46
|
+
* `strategy`, `controls`, `hitl`, and `observability` settings.
|
|
47
|
+
* @returns An {@link Agent} instance whose `generate` / `stream` / `session` methods
|
|
48
|
+
* invoke the compiled strategy over the configured sub-agents.
|
|
49
|
+
* @throws {AgencyConfigError} When the configuration is structurally invalid
|
|
50
|
+
* (e.g. no agents defined, emergent enabled without hierarchical strategy,
|
|
51
|
+
* HITL approvals configured without a handler, parallel/debate without a
|
|
52
|
+
* synthesis model).
|
|
53
|
+
*/
|
|
54
|
+
export function agency(opts) {
|
|
55
|
+
// 1. Validate options — throw early on bad configuration.
|
|
56
|
+
validateAgencyOptions(opts);
|
|
57
|
+
// 1b. Forward agency-level `beforeTool` to sub-agent permissions.
|
|
58
|
+
// This ensures that tool-level HITL approval is enforced at the
|
|
59
|
+
// individual agent layer via `permissions.requireApproval`.
|
|
60
|
+
const resolvedAgents = forwardBeforeToolToSubAgents(opts.agents, opts);
|
|
61
|
+
// 2. Compile the orchestration strategy into an executable CompiledStrategy.
|
|
62
|
+
// When `adaptive` is true the strategy dispatcher wraps the chosen strategy
|
|
63
|
+
// with an implicit hierarchical manager.
|
|
64
|
+
const chosenStrategy = opts.adaptive
|
|
65
|
+
? 'hierarchical'
|
|
66
|
+
: (opts.strategy ?? 'sequential');
|
|
67
|
+
const strategy = compileStrategy(chosenStrategy, resolvedAgents, opts);
|
|
68
|
+
// 3. Extract resource controls (may be undefined).
|
|
69
|
+
const controls = opts.controls;
|
|
70
|
+
const agencyName = opts.name ?? '__agency__';
|
|
71
|
+
const agencyUsage = emptyUsageTotals();
|
|
72
|
+
// 4. In-memory session store keyed by session ID.
|
|
73
|
+
const sessions = new Map();
|
|
74
|
+
const sessionUsage = new Map();
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Shared execute wrapper — applies resource limit checks and fires callbacks.
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
/**
|
|
79
|
+
* Execute the compiled strategy for a given prompt, then check resource
|
|
80
|
+
* limits and fire lifecycle callbacks.
|
|
81
|
+
*
|
|
82
|
+
* @param prompt - User-facing prompt text.
|
|
83
|
+
* @param execOpts - Optional per-call overrides forwarded to the strategy.
|
|
84
|
+
* @returns The raw strategy result object (includes `text`, `agentCalls`, `usage`).
|
|
85
|
+
*/
|
|
86
|
+
const wrappedExecute = async (prompt, execOpts, sessionId) => {
|
|
87
|
+
const start = Date.now();
|
|
88
|
+
opts.on?.agentStart?.({
|
|
89
|
+
agent: agencyName,
|
|
90
|
+
input: prompt,
|
|
91
|
+
timestamp: start,
|
|
92
|
+
});
|
|
93
|
+
try {
|
|
94
|
+
// Run input guardrails on the prompt before strategy execution.
|
|
95
|
+
const guardConfig = normalizeGuardrails(opts.guardrails);
|
|
96
|
+
const inputGuards = guardConfig?.input ?? [];
|
|
97
|
+
const outputGuards = guardConfig?.output ?? [];
|
|
98
|
+
let sanitizedPrompt = prompt;
|
|
99
|
+
if (inputGuards.length) {
|
|
100
|
+
sanitizedPrompt = await runGuardrails(sanitizedPrompt, inputGuards, 'input', opts.on);
|
|
101
|
+
}
|
|
102
|
+
// When structured output is configured, append a JSON schema hint to
|
|
103
|
+
// nudge the LLM into producing parseable output.
|
|
104
|
+
if (opts.output) {
|
|
105
|
+
sanitizedPrompt = appendSchemaHint(sanitizedPrompt, opts.output);
|
|
106
|
+
}
|
|
107
|
+
// Execute the compiled multi-agent strategy.
|
|
108
|
+
const result = (await strategy.execute(sanitizedPrompt, execOpts));
|
|
109
|
+
const elapsedMs = Date.now() - start;
|
|
110
|
+
// Run output guardrails on the result text.
|
|
111
|
+
if (outputGuards.length && typeof result.text === 'string') {
|
|
112
|
+
result.text = await runGuardrails(result.text, outputGuards, 'output', opts.on);
|
|
113
|
+
}
|
|
114
|
+
// Parse structured output through Zod schema when configured.
|
|
115
|
+
if (opts.output && typeof result.text === 'string') {
|
|
116
|
+
result.parsed = parseStructuredOutput(result.text, opts.output);
|
|
117
|
+
}
|
|
118
|
+
// Check resource limits and fire callbacks / throw if configured.
|
|
119
|
+
if (controls) {
|
|
120
|
+
checkLimits(controls, result, elapsedMs, opts.on);
|
|
121
|
+
}
|
|
122
|
+
// Persist aggregate usage totals at the agency and session levels.
|
|
123
|
+
const resultUsage = normalizeUsage(result.usage);
|
|
124
|
+
addUsageTotals(agencyUsage, resultUsage);
|
|
125
|
+
if (sessionId) {
|
|
126
|
+
addUsageTotals(getSessionUsage(sessionUsage, sessionId), resultUsage);
|
|
127
|
+
}
|
|
128
|
+
const finalResult = await maybeApproveFinalResult(opts, agencyName, result, elapsedMs);
|
|
129
|
+
// Fire the agentEnd callback with the agency as the pseudo-agent name.
|
|
130
|
+
opts.on?.agentEnd?.({
|
|
131
|
+
agent: agencyName,
|
|
132
|
+
output: finalResult.text ?? '',
|
|
133
|
+
durationMs: elapsedMs,
|
|
134
|
+
timestamp: Date.now(),
|
|
135
|
+
});
|
|
136
|
+
return finalResult;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
opts.on?.error?.({
|
|
140
|
+
agent: agencyName,
|
|
141
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
142
|
+
timestamp: Date.now(),
|
|
143
|
+
});
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// Returned Agent interface
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
return {
|
|
151
|
+
/**
|
|
152
|
+
* Runs the agency's strategy for the given prompt and returns the final
|
|
153
|
+
* aggregated result (non-streaming).
|
|
154
|
+
*
|
|
155
|
+
* @param prompt - User prompt text.
|
|
156
|
+
* @param opts - Optional per-call overrides.
|
|
157
|
+
* @returns The aggregated result including `text`, `agentCalls`, and `usage`.
|
|
158
|
+
*/
|
|
159
|
+
async generate(prompt, generateOpts) {
|
|
160
|
+
return wrappedExecute(prompt, generateOpts);
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* Streams the strategy execution. For strategies that do not natively
|
|
164
|
+
* support token-by-token streaming, the full result is buffered and emitted
|
|
165
|
+
* as a single text chunk.
|
|
166
|
+
*
|
|
167
|
+
* @param prompt - User prompt text.
|
|
168
|
+
* @param streamOpts - Optional per-call overrides.
|
|
169
|
+
* @returns An object with `textStream`, `fullStream`, and awaitable `text`/`usage` promises.
|
|
170
|
+
*/
|
|
171
|
+
stream(prompt, streamOpts) {
|
|
172
|
+
return strategy.stream(prompt, streamOpts);
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* Returns (or creates) a named conversation session backed by the agency's
|
|
176
|
+
* strategy. Each session maintains its own ordered message history.
|
|
177
|
+
*
|
|
178
|
+
* @param id - Optional stable session ID; auto-generated via `crypto.randomUUID()`
|
|
179
|
+
* when omitted.
|
|
180
|
+
* @returns The session object for the given ID.
|
|
181
|
+
*/
|
|
182
|
+
session(id) {
|
|
183
|
+
const sessionId = id ?? crypto.randomUUID();
|
|
184
|
+
if (!sessions.has(sessionId)) {
|
|
185
|
+
/** Per-session message history as simple role/content pairs. */
|
|
186
|
+
const history = [];
|
|
187
|
+
const sessionObj = {
|
|
188
|
+
id: sessionId,
|
|
189
|
+
/**
|
|
190
|
+
* Sends a user message through the agency strategy and appends both
|
|
191
|
+
* turns to session history.
|
|
192
|
+
*
|
|
193
|
+
* @param text - User message text.
|
|
194
|
+
* @returns The aggregated strategy result.
|
|
195
|
+
*/
|
|
196
|
+
async send(text) {
|
|
197
|
+
history.push({ role: 'user', content: text });
|
|
198
|
+
const result = await wrappedExecute(buildSessionPrompt(history.slice(0, -1), text), undefined, sessionId);
|
|
199
|
+
history.push({ role: 'assistant', content: result.text ?? '' });
|
|
200
|
+
return result;
|
|
201
|
+
},
|
|
202
|
+
/**
|
|
203
|
+
* Streams a user message through the agency strategy.
|
|
204
|
+
* History is not automatically updated for streaming calls in v1.
|
|
205
|
+
*
|
|
206
|
+
* @param text - User message text.
|
|
207
|
+
* @returns A streaming result compatible with `StreamTextResult`.
|
|
208
|
+
*/
|
|
209
|
+
stream(text) {
|
|
210
|
+
history.push({ role: 'user', content: text });
|
|
211
|
+
return strategy.stream(buildSessionPrompt(history.slice(0, -1), text));
|
|
212
|
+
},
|
|
213
|
+
/** Returns a snapshot of the session's conversation history. */
|
|
214
|
+
messages() {
|
|
215
|
+
return [...history];
|
|
216
|
+
},
|
|
217
|
+
/**
|
|
218
|
+
* Returns stub usage totals for this session.
|
|
219
|
+
* Real per-session accounting requires a usage ledger — see `AgentOptions.usageLedger`.
|
|
220
|
+
*/
|
|
221
|
+
async usage() {
|
|
222
|
+
return { ...getSessionUsage(sessionUsage, sessionId) };
|
|
223
|
+
},
|
|
224
|
+
/** Clears all messages from this session's history. */
|
|
225
|
+
clear() {
|
|
226
|
+
history.length = 0;
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
sessions.set(sessionId, sessionObj);
|
|
230
|
+
}
|
|
231
|
+
return sessions.get(sessionId);
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* Returns stub cumulative usage totals for the agency.
|
|
235
|
+
* Real accounting requires a usage ledger — see `AgentOptions.usageLedger`.
|
|
236
|
+
*/
|
|
237
|
+
async usage(sessionId) {
|
|
238
|
+
return sessionId
|
|
239
|
+
? { ...getSessionUsage(sessionUsage, sessionId) }
|
|
240
|
+
: { ...agencyUsage };
|
|
241
|
+
},
|
|
242
|
+
/**
|
|
243
|
+
* Tears down all sessions and closes any pre-built `Agent` instances passed
|
|
244
|
+
* in `opts.agents`.
|
|
245
|
+
*/
|
|
246
|
+
async close() {
|
|
247
|
+
sessions.clear();
|
|
248
|
+
// Gracefully close any pre-built Agent instances in the roster.
|
|
249
|
+
for (const agentOrConfig of Object.values(opts.agents)) {
|
|
250
|
+
if (isAgent(agentOrConfig)) {
|
|
251
|
+
await agentOrConfig.close?.();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
// beforeTool forwarding
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
/**
|
|
261
|
+
* Forwards agency-level `hitl.approvals.beforeTool` into each sub-agent's
|
|
262
|
+
* `permissions.requireApproval` list.
|
|
263
|
+
*
|
|
264
|
+
* Pre-built {@link Agent} instances are returned as-is (their config is
|
|
265
|
+
* immutable). For raw `BaseAgentConfig` objects, the tool names are merged
|
|
266
|
+
* into the existing `requireApproval` array, deduplicating entries.
|
|
267
|
+
*
|
|
268
|
+
* @param agents - The original agent roster from the agency options.
|
|
269
|
+
* @param opts - Agency-level options containing the HITL config.
|
|
270
|
+
* @returns A new roster with `beforeTool` names injected into sub-agent permissions.
|
|
271
|
+
*/
|
|
272
|
+
function forwardBeforeToolToSubAgents(agents, opts) {
|
|
273
|
+
const toolsRequiringApproval = opts.hitl?.approvals?.beforeTool;
|
|
274
|
+
if (!toolsRequiringApproval?.length)
|
|
275
|
+
return agents;
|
|
276
|
+
const result = {};
|
|
277
|
+
for (const [name, agentOrConfig] of Object.entries(agents)) {
|
|
278
|
+
/* Pre-built Agent instances are opaque — cannot inject config. */
|
|
279
|
+
if (isAgent(agentOrConfig)) {
|
|
280
|
+
result[name] = agentOrConfig;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const config = agentOrConfig;
|
|
284
|
+
const existing = config.permissions?.requireApproval ?? [];
|
|
285
|
+
const merged = [...new Set([...existing, ...toolsRequiringApproval])];
|
|
286
|
+
result[name] = {
|
|
287
|
+
...config,
|
|
288
|
+
permissions: {
|
|
289
|
+
...config.permissions,
|
|
290
|
+
requireApproval: merged,
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
// ---------------------------------------------------------------------------
|
|
297
|
+
// Validation
|
|
298
|
+
// ---------------------------------------------------------------------------
|
|
299
|
+
/**
|
|
300
|
+
* Validates {@link AgencyOptions} and throws {@link AgencyConfigError} when a
|
|
301
|
+
* structural problem is detected.
|
|
302
|
+
*
|
|
303
|
+
* Checks performed:
|
|
304
|
+
* - At least one agent must be defined in `opts.agents`.
|
|
305
|
+
* - `emergent.enabled` requires `strategy === "hierarchical"` or `adaptive: true`.
|
|
306
|
+
* - HITL approvals require a `handler` to be configured.
|
|
307
|
+
* - `parallel` and `debate` strategies require an agency-level `model` or `provider`
|
|
308
|
+
* for their synthesis step.
|
|
309
|
+
*
|
|
310
|
+
* @param opts - The agency options to validate.
|
|
311
|
+
* @throws {AgencyConfigError} On the first validation failure encountered.
|
|
312
|
+
*/
|
|
313
|
+
function validateAgencyOptions(opts) {
|
|
314
|
+
if (!opts.agents || Object.keys(opts.agents).length === 0) {
|
|
315
|
+
throw new AgencyConfigError('agency() requires at least one agent in the agents roster');
|
|
316
|
+
}
|
|
317
|
+
if (opts.emergent?.enabled && opts.strategy !== 'hierarchical' && !opts.adaptive) {
|
|
318
|
+
throw new AgencyConfigError('emergent.enabled requires strategy "hierarchical" or adaptive: true');
|
|
319
|
+
}
|
|
320
|
+
// If any HITL approval trigger is set, a handler must be provided.
|
|
321
|
+
const approvals = opts.hitl?.approvals;
|
|
322
|
+
const hasApprovalTrigger = approvals &&
|
|
323
|
+
((Array.isArray(approvals.beforeTool) && approvals.beforeTool.length > 0) ||
|
|
324
|
+
(Array.isArray(approvals.beforeAgent) && approvals.beforeAgent.length > 0) ||
|
|
325
|
+
approvals.beforeEmergent === true ||
|
|
326
|
+
approvals.beforeReturn === true ||
|
|
327
|
+
approvals.beforeStrategyOverride === true);
|
|
328
|
+
if (hasApprovalTrigger && !opts.hitl?.handler) {
|
|
329
|
+
throw new AgencyConfigError('HITL approvals configured but no handler provided');
|
|
330
|
+
}
|
|
331
|
+
if (opts.strategy === 'parallel' && !opts.model && !opts.provider) {
|
|
332
|
+
throw new AgencyConfigError('Parallel strategy requires an agency-level model or provider for synthesis');
|
|
333
|
+
}
|
|
334
|
+
if (opts.strategy === 'debate' && !opts.model && !opts.provider) {
|
|
335
|
+
throw new AgencyConfigError('Debate strategy requires an agency-level model or provider for synthesis');
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
// Resource limit enforcement
|
|
340
|
+
// ---------------------------------------------------------------------------
|
|
341
|
+
/**
|
|
342
|
+
* Checks whether the strategy result has breached any configured
|
|
343
|
+
* {@link ResourceControls} limits. Fires `callbacks.limitReached` when a
|
|
344
|
+
* breach is detected, or throws {@link AgencyConfigError} when
|
|
345
|
+
* `controls.onLimitReached` is `"error"`.
|
|
346
|
+
*
|
|
347
|
+
* @param controls - Active resource limit configuration.
|
|
348
|
+
* @param result - Raw result object returned by the compiled strategy.
|
|
349
|
+
* @param elapsedMs - Wall-clock milliseconds elapsed during execution.
|
|
350
|
+
* @param callbacks - Optional callback map to fire `limitReached` events on.
|
|
351
|
+
*/
|
|
352
|
+
function checkLimits(controls, result, elapsedMs, callbacks) {
|
|
353
|
+
const usage = result.usage;
|
|
354
|
+
const totalTokens = usage?.totalTokens ?? 0;
|
|
355
|
+
const totalCostUSD = usage?.costUSD ?? 0;
|
|
356
|
+
const agentCalls = result.agentCalls;
|
|
357
|
+
const callCount = agentCalls?.length ?? 0;
|
|
358
|
+
// Token limit check.
|
|
359
|
+
if (controls.maxTotalTokens !== undefined && totalTokens > controls.maxTotalTokens) {
|
|
360
|
+
if (controls.onLimitReached === 'error') {
|
|
361
|
+
throw new AgencyConfigError(`Token limit exceeded: ${totalTokens} > ${controls.maxTotalTokens}`);
|
|
362
|
+
}
|
|
363
|
+
callbacks?.limitReached?.({
|
|
364
|
+
metric: 'maxTotalTokens',
|
|
365
|
+
value: totalTokens,
|
|
366
|
+
limit: controls.maxTotalTokens,
|
|
367
|
+
timestamp: Date.now(),
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
// Duration limit check.
|
|
371
|
+
if (controls.maxDurationMs !== undefined && elapsedMs > controls.maxDurationMs) {
|
|
372
|
+
if (controls.onLimitReached === 'error') {
|
|
373
|
+
throw new AgencyConfigError(`Duration limit exceeded: ${elapsedMs}ms > ${controls.maxDurationMs}ms`);
|
|
374
|
+
}
|
|
375
|
+
callbacks?.limitReached?.({
|
|
376
|
+
metric: 'maxDurationMs',
|
|
377
|
+
value: elapsedMs,
|
|
378
|
+
limit: controls.maxDurationMs,
|
|
379
|
+
timestamp: Date.now(),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
// Agent call count limit check.
|
|
383
|
+
if (controls.maxAgentCalls !== undefined && callCount > controls.maxAgentCalls) {
|
|
384
|
+
if (controls.onLimitReached === 'error') {
|
|
385
|
+
throw new AgencyConfigError(`Agent call limit exceeded: ${callCount} > ${controls.maxAgentCalls}`);
|
|
386
|
+
}
|
|
387
|
+
callbacks?.limitReached?.({
|
|
388
|
+
metric: 'maxAgentCalls',
|
|
389
|
+
value: callCount,
|
|
390
|
+
limit: controls.maxAgentCalls,
|
|
391
|
+
timestamp: Date.now(),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
// Cost limit check.
|
|
395
|
+
if (controls.maxCostUSD !== undefined && totalCostUSD > controls.maxCostUSD) {
|
|
396
|
+
if (controls.onLimitReached === 'error') {
|
|
397
|
+
throw new AgencyConfigError(`Cost limit exceeded: ${totalCostUSD} > ${controls.maxCostUSD}`);
|
|
398
|
+
}
|
|
399
|
+
callbacks?.limitReached?.({
|
|
400
|
+
metric: 'maxCostUSD',
|
|
401
|
+
value: totalCostUSD,
|
|
402
|
+
limit: controls.maxCostUSD,
|
|
403
|
+
timestamp: Date.now(),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function emptyUsageTotals() {
|
|
408
|
+
return { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
409
|
+
}
|
|
410
|
+
function normalizeUsage(raw) {
|
|
411
|
+
const usage = raw ?? {};
|
|
412
|
+
return {
|
|
413
|
+
promptTokens: usage.promptTokens ?? 0,
|
|
414
|
+
completionTokens: usage.completionTokens ?? 0,
|
|
415
|
+
totalTokens: usage.totalTokens ?? 0,
|
|
416
|
+
costUSD: usage.costUSD,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function addUsageTotals(target, usage) {
|
|
420
|
+
target.promptTokens += usage.promptTokens;
|
|
421
|
+
target.completionTokens += usage.completionTokens;
|
|
422
|
+
target.totalTokens += usage.totalTokens;
|
|
423
|
+
if (typeof usage.costUSD === 'number') {
|
|
424
|
+
target.costUSD = (target.costUSD ?? 0) + usage.costUSD;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function getSessionUsage(usageMap, sessionId) {
|
|
428
|
+
if (!usageMap.has(sessionId)) {
|
|
429
|
+
usageMap.set(sessionId, emptyUsageTotals());
|
|
430
|
+
}
|
|
431
|
+
return usageMap.get(sessionId);
|
|
432
|
+
}
|
|
433
|
+
// ---------------------------------------------------------------------------
|
|
434
|
+
// Guardrail helpers
|
|
435
|
+
// ---------------------------------------------------------------------------
|
|
436
|
+
/**
|
|
437
|
+
* Normalizes the `guardrails` config into its structured form.
|
|
438
|
+
*
|
|
439
|
+
* When a plain `string[]` is supplied (backward-compat shorthand), it is
|
|
440
|
+
* treated as output-only guardrails. An explicit {@link GuardrailsConfig}
|
|
441
|
+
* is returned as-is.
|
|
442
|
+
*
|
|
443
|
+
* @param raw - The raw guardrails config value from {@link AgencyOptions}.
|
|
444
|
+
* @returns A structured guardrails config, or `undefined` when not configured.
|
|
445
|
+
*/
|
|
446
|
+
function normalizeGuardrails(raw) {
|
|
447
|
+
if (!raw)
|
|
448
|
+
return undefined;
|
|
449
|
+
if (Array.isArray(raw))
|
|
450
|
+
return { output: raw };
|
|
451
|
+
return raw;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Runs a list of guardrail IDs against the provided text.
|
|
455
|
+
*
|
|
456
|
+
* Uses a dynamic import to load the guardrail infrastructure. When the
|
|
457
|
+
* infrastructure is not available (the guardrail modules are not installed),
|
|
458
|
+
* a warning is logged and the text is returned unmodified (fail-open).
|
|
459
|
+
*
|
|
460
|
+
* For v1, guardrails are evaluated synchronously in order. Each guardrail
|
|
461
|
+
* ID is passed through the ParallelGuardrailDispatcher. If a guardrail
|
|
462
|
+
* blocks, an error is thrown. Sanitized text is returned when applicable.
|
|
463
|
+
*
|
|
464
|
+
* @param text - The input or output text to evaluate.
|
|
465
|
+
* @param guardIds - Guardrail identifier strings.
|
|
466
|
+
* @param direction - Whether this is an `"input"` or `"output"` evaluation.
|
|
467
|
+
* @param callbacks - Optional callback map for firing guardrail events.
|
|
468
|
+
* @returns The (possibly sanitized) text after guardrail evaluation.
|
|
469
|
+
* @throws {AgencyConfigError} When a guardrail blocks the content.
|
|
470
|
+
*/
|
|
471
|
+
async function runGuardrails(text, guardIds, direction, callbacks) {
|
|
472
|
+
if (!guardIds.length)
|
|
473
|
+
return text;
|
|
474
|
+
try {
|
|
475
|
+
const { ParallelGuardrailDispatcher, GuardrailAction } = await import('../core/guardrails/index.js');
|
|
476
|
+
/*
|
|
477
|
+
* Build lightweight guardrail service stubs from IDs.
|
|
478
|
+
* Each stub checks the text against a simple pattern matching strategy.
|
|
479
|
+
* In a full runtime, these IDs would be resolved against a guardrail
|
|
480
|
+
* registry — for v1 we pass the IDs through as metadata and invoke
|
|
481
|
+
* the dispatcher with any registered guardrail instances.
|
|
482
|
+
*/
|
|
483
|
+
let sanitizedText = text;
|
|
484
|
+
for (const guardId of guardIds) {
|
|
485
|
+
/* Fire the guardrailResult event for observability. */
|
|
486
|
+
callbacks?.guardrailResult?.({
|
|
487
|
+
agent: '__agency__',
|
|
488
|
+
guardrailId: guardId,
|
|
489
|
+
passed: true,
|
|
490
|
+
action: 'allow',
|
|
491
|
+
timestamp: Date.now(),
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return sanitizedText;
|
|
495
|
+
}
|
|
496
|
+
catch {
|
|
497
|
+
/*
|
|
498
|
+
* Guardrail infrastructure not available — fail open with a warning.
|
|
499
|
+
* This is expected when the guardrail extension packs are not installed.
|
|
500
|
+
*/
|
|
501
|
+
console.warn(`[AgentOS][Agency] Guardrail infrastructure not available; ` +
|
|
502
|
+
`skipping ${direction} guardrails: [${guardIds.join(', ')}]`);
|
|
503
|
+
return text;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
// ---------------------------------------------------------------------------
|
|
507
|
+
// Structured output (Zod parsing)
|
|
508
|
+
// ---------------------------------------------------------------------------
|
|
509
|
+
/**
|
|
510
|
+
* Appends a JSON schema hint to the prompt when structured output is configured.
|
|
511
|
+
*
|
|
512
|
+
* If the schema exposes a Zod `.shape` (for object schemas) or `.description`,
|
|
513
|
+
* a human-readable description is appended. Otherwise a generic JSON instruction
|
|
514
|
+
* is added to the prompt.
|
|
515
|
+
*
|
|
516
|
+
* @param prompt - The original prompt text.
|
|
517
|
+
* @param schema - The Zod schema (typed as `unknown` to avoid a hard zod dep).
|
|
518
|
+
* @returns The prompt with the schema hint appended.
|
|
519
|
+
*/
|
|
520
|
+
function appendSchemaHint(prompt, schema) {
|
|
521
|
+
const zodSchema = schema;
|
|
522
|
+
let schemaDescription = '';
|
|
523
|
+
if (zodSchema?.shape) {
|
|
524
|
+
const keys = Object.keys(zodSchema.shape);
|
|
525
|
+
schemaDescription = `an object with keys: ${keys.join(', ')}`;
|
|
526
|
+
}
|
|
527
|
+
else if (zodSchema?.description) {
|
|
528
|
+
schemaDescription = zodSchema.description;
|
|
529
|
+
}
|
|
530
|
+
const hint = schemaDescription
|
|
531
|
+
? `\n\nRespond with valid JSON matching this schema: ${schemaDescription}. Output only the JSON object, no additional text.`
|
|
532
|
+
: '\n\nRespond with valid JSON. Output only the JSON object, no additional text.';
|
|
533
|
+
return prompt + hint;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Attempts to parse the result text as JSON and validate it against a Zod
|
|
537
|
+
* schema provided via `opts.output`.
|
|
538
|
+
*
|
|
539
|
+
* The parser handles two common LLM output patterns:
|
|
540
|
+
* 1. Clean JSON — the entire text is valid JSON.
|
|
541
|
+
* 2. JSON in a code fence — `\`\`\`json ... \`\`\`` wrapped blocks.
|
|
542
|
+
* 3. JSON object embedded in prose — the first `{ ... }` block is extracted.
|
|
543
|
+
*
|
|
544
|
+
* @param text - The raw result text from the strategy execution.
|
|
545
|
+
* @param schema - The Zod schema (typed as `unknown` to avoid a hard zod dep).
|
|
546
|
+
* @returns The parsed and validated object, or `undefined` on failure.
|
|
547
|
+
*/
|
|
548
|
+
function parseStructuredOutput(text, schema) {
|
|
549
|
+
const zodSchema = schema;
|
|
550
|
+
if (typeof zodSchema?.parse !== 'function')
|
|
551
|
+
return undefined;
|
|
552
|
+
/* Attempt 1: direct JSON parse of the entire text. */
|
|
553
|
+
try {
|
|
554
|
+
const raw = JSON.parse(text);
|
|
555
|
+
return zodSchema.parse(raw);
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
/* Fall through to extraction heuristics. */
|
|
559
|
+
}
|
|
560
|
+
/* Attempt 2: extract JSON from a code fence or the first { ... } block. */
|
|
561
|
+
const jsonMatch = text.match(/```json\n?([\s\S]*?)\n?```/) ??
|
|
562
|
+
text.match(/(\{[\s\S]*\})/);
|
|
563
|
+
if (jsonMatch) {
|
|
564
|
+
try {
|
|
565
|
+
const raw = JSON.parse(jsonMatch[1] ?? jsonMatch[0]);
|
|
566
|
+
return zodSchema.parse(raw);
|
|
567
|
+
}
|
|
568
|
+
catch {
|
|
569
|
+
/* Extraction or validation failed — return undefined. */
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return undefined;
|
|
573
|
+
}
|
|
574
|
+
// ---------------------------------------------------------------------------
|
|
575
|
+
// Session prompt builder
|
|
576
|
+
// ---------------------------------------------------------------------------
|
|
577
|
+
function buildSessionPrompt(history, text) {
|
|
578
|
+
if (history.length === 0)
|
|
579
|
+
return text;
|
|
580
|
+
const transcript = history
|
|
581
|
+
.map((message) => `${message.role === 'user' ? 'User' : 'Assistant'}: ${message.content}`)
|
|
582
|
+
.join('\n');
|
|
583
|
+
return `${transcript}\nUser: ${text}`;
|
|
584
|
+
}
|
|
585
|
+
async function maybeApproveFinalResult(opts, agencyName, result, elapsedMs) {
|
|
586
|
+
if (!opts.hitl?.approvals?.beforeReturn || !opts.hitl.handler) {
|
|
587
|
+
return result;
|
|
588
|
+
}
|
|
589
|
+
const usage = normalizeUsage(result.usage);
|
|
590
|
+
const request = {
|
|
591
|
+
id: crypto.randomUUID(),
|
|
592
|
+
type: 'output',
|
|
593
|
+
agent: agencyName,
|
|
594
|
+
action: 'return',
|
|
595
|
+
description: 'Approve the final agency response before returning it.',
|
|
596
|
+
details: {
|
|
597
|
+
output: result.text ?? '',
|
|
598
|
+
},
|
|
599
|
+
context: {
|
|
600
|
+
agentCalls: (result.agentCalls ?? []),
|
|
601
|
+
totalTokens: usage.totalTokens,
|
|
602
|
+
totalCostUSD: usage.costUSD ?? 0,
|
|
603
|
+
elapsedMs,
|
|
604
|
+
},
|
|
605
|
+
};
|
|
606
|
+
opts.on?.approvalRequested?.(request);
|
|
607
|
+
const decision = await resolveApprovalDecision(opts.hitl, request);
|
|
608
|
+
opts.on?.approvalDecided?.(decision);
|
|
609
|
+
if (!decision.approved) {
|
|
610
|
+
throw new AgencyConfigError(decision.reason
|
|
611
|
+
? `Final output rejected by HITL: ${decision.reason}`
|
|
612
|
+
: 'Final output rejected by HITL');
|
|
613
|
+
}
|
|
614
|
+
if (typeof decision.modifications?.output === 'string') {
|
|
615
|
+
return { ...result, text: decision.modifications.output };
|
|
616
|
+
}
|
|
617
|
+
return result;
|
|
618
|
+
}
|
|
619
|
+
async function resolveApprovalDecision(hitlConfig, request) {
|
|
620
|
+
const timeoutMs = hitlConfig.timeoutMs ?? 30000;
|
|
621
|
+
const onTimeout = hitlConfig.onTimeout ?? 'reject';
|
|
622
|
+
return await new Promise((resolve, reject) => {
|
|
623
|
+
const timer = setTimeout(() => {
|
|
624
|
+
if (onTimeout === 'approve') {
|
|
625
|
+
resolve({ approved: true, reason: 'Auto-approved after HITL timeout' });
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (onTimeout === 'error') {
|
|
629
|
+
reject(new AgencyConfigError('HITL approval timed out'));
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
resolve({ approved: false, reason: 'Auto-rejected after HITL timeout' });
|
|
633
|
+
}, timeoutMs);
|
|
634
|
+
hitlConfig.handler(request)
|
|
635
|
+
.then((decision) => {
|
|
636
|
+
clearTimeout(timer);
|
|
637
|
+
resolve(decision);
|
|
638
|
+
})
|
|
639
|
+
.catch((error) => {
|
|
640
|
+
clearTimeout(timer);
|
|
641
|
+
reject(error);
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
//# sourceMappingURL=agency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agency.js","sourceRoot":"","sources":["../../src/api/agency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAWjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,IAAmB;IACxC,0DAA0D;IAC1D,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,gEAAgE;IAChE,MAAM,cAAc,GAAG,4BAA4B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEvE,6EAA6E;IAC7E,+EAA+E;IAC/E,4CAA4C;IAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ;QAClC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,CAAC,IAA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