@directive-run/ai 0.8.5 → 0.8.7
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 +7 -0
- package/dist/anthropic.cjs +2 -3
- package/dist/anthropic.cjs.map +1 -1
- package/dist/anthropic.d.cts +1 -1
- package/dist/anthropic.d.ts +1 -1
- package/dist/anthropic.js +2 -3
- package/dist/anthropic.js.map +1 -1
- package/dist/chunk-265ZKXYE.js +3 -0
- package/dist/chunk-265ZKXYE.js.map +1 -0
- package/dist/chunk-7EJPXKDP.js +50 -0
- package/dist/chunk-7EJPXKDP.js.map +1 -0
- package/dist/chunk-B4ATEGA2.cjs +50 -0
- package/dist/chunk-B4ATEGA2.cjs.map +1 -0
- package/dist/chunk-MNYANBNX.js +14 -0
- package/dist/chunk-MNYANBNX.js.map +1 -0
- package/dist/chunk-QXMXSHYS.cjs +3 -0
- package/dist/chunk-QXMXSHYS.cjs.map +1 -0
- package/dist/chunk-W6MVJKWN.cjs +3 -0
- package/dist/chunk-W6MVJKWN.cjs.map +1 -0
- package/dist/chunk-W6WZBQER.js +3 -0
- package/dist/chunk-W6WZBQER.js.map +1 -0
- package/dist/chunk-WCJFIC22.cjs +14 -0
- package/dist/chunk-WCJFIC22.cjs.map +1 -0
- package/dist/gemini.cjs +2 -3
- package/dist/gemini.cjs.map +1 -1
- package/dist/gemini.d.cts +1 -1
- package/dist/gemini.d.ts +1 -1
- package/dist/gemini.js +2 -3
- package/dist/gemini.js.map +1 -1
- package/dist/index.cjs +30 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -27
- package/dist/index.d.ts +194 -27
- package/dist/index.js +30 -89
- package/dist/index.js.map +1 -1
- package/dist/multi-agent-orchestrator-FEHVHZXA.js +2 -0
- package/dist/multi-agent-orchestrator-FEHVHZXA.js.map +1 -0
- package/dist/multi-agent-orchestrator-QWJNM4EZ.cjs +2 -0
- package/dist/multi-agent-orchestrator-QWJNM4EZ.cjs.map +1 -0
- package/dist/ollama.cjs +2 -2
- package/dist/ollama.cjs.map +1 -1
- package/dist/ollama.d.cts +1 -1
- package/dist/ollama.d.ts +1 -1
- package/dist/ollama.js +2 -2
- package/dist/ollama.js.map +1 -1
- package/dist/openai.cjs +2 -3
- package/dist/openai.cjs.map +1 -1
- package/dist/openai.d.cts +2 -2
- package/dist/openai.d.ts +2 -2
- package/dist/openai.js +2 -3
- package/dist/openai.js.map +1 -1
- package/dist/{multi-agent-orchestrator-DHp8gHXi.d.ts → orchestrator-types-DryFJyW9.d.ts} +6 -142
- package/dist/{multi-agent-orchestrator-C3VKkLzg.d.cts → orchestrator-types-tATJCBi5.d.cts} +6 -142
- package/dist/{semantic-cache-F0psCRuz.d.cts → semantic-cache-nBpQqILc.d.cts} +5 -5
- package/dist/{semantic-cache-F0psCRuz.d.ts → semantic-cache-nBpQqILc.d.ts} +5 -5
- package/dist/testing.cjs +1 -48
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -48
- package/dist/testing.js.map +1 -1
- package/dist/{types-BM-6xZf_.d.cts → types-CRmwFnVk.d.cts} +1 -1
- package/dist/{types-BM-6xZf_.d.ts → types-CRmwFnVk.d.ts} +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Message$1,
|
|
1
|
+
import { M as Message$1, n as RunResult, A as AgentLike, G as GuardrailFn, O as OutputGuardrailData, aX as StreamingCallbackRunner, q as DebugEvent, a8 as DebugEventType, b as AgentRunner, az as OrchestratorState, au as NamedGuardrail, I as InputGuardrailData, W as Checkpoint, L as BreakpointModifications, N as BreakpointRequest, o as OrchestratorConstraint, ax as OrchestratorResolver, aj as GuardrailsConfig, z as ApprovalRequest, av as OrchestratorDebugConfig, w as AgentRetryConfig, aw as OrchestratorLifecycleHooks, aU as SelfHealingConfig, e as CheckpointStore, H as BreakpointConfig, am as HealthMonitorConfig, p as RunOptions, T as ToolCallGuardrailData, l as PatternCheckpointConfig, i as DagPattern, m as GoalPattern, j as GoalNode, g as AgentSelectionStrategy, R as RelaxationTier, r as GoalResult, ab as GoalCheckpointState, aV as SequentialCheckpointState, aY as SupervisorCheckpointState, aG as ReflectCheckpointState, a5 as DebateCheckpointState, a2 as DagCheckpointState, aS as Scratchpad, as as MultiAgentLifecycleHooks, at as MultiAgentSelfHealingConfig, aq as MultiAgentBreakpointType, a0 as CrossAgentDerivationFn } from './types-CRmwFnVk.cjs';
|
|
2
2
|
import { Plugin, System, Requirement } from '@directive-run/core';
|
|
3
3
|
import { CircuitBreaker } from '@directive-run/core/plugins';
|
|
4
4
|
|
|
@@ -998,8 +998,8 @@ interface AgentOrchestrator<F extends Record<string, unknown>> {
|
|
|
998
998
|
cancelBreakpoint(id: string, reason?: string): void;
|
|
999
999
|
/** Get all currently pending breakpoint requests. */
|
|
1000
1000
|
getPendingBreakpoints(): BreakpointRequest[];
|
|
1001
|
-
/**
|
|
1002
|
-
|
|
1001
|
+
/** Destroy the orchestrator, releasing all resources. */
|
|
1002
|
+
destroy(): void;
|
|
1003
1003
|
}
|
|
1004
1004
|
/**
|
|
1005
1005
|
* Create a constraint-driven agent orchestrator backed by a Directive System.
|
|
@@ -1208,97 +1208,6 @@ declare class ReflectionExhaustedError extends Error {
|
|
|
1208
1208
|
*/
|
|
1209
1209
|
declare function withReflection<T = unknown>(runner: AgentRunner, config: ReflectionConfig<T>): AgentRunner;
|
|
1210
1210
|
|
|
1211
|
-
/**
|
|
1212
|
-
* Get the current step/round/iteration count from a pattern checkpoint state.
|
|
1213
|
-
*
|
|
1214
|
-
* Maps each pattern type to its natural progress counter: `step` for sequential
|
|
1215
|
-
* and goal, `round` for supervisor and debate, `iteration` for reflect, and
|
|
1216
|
-
* `completedCount` for DAG.
|
|
1217
|
-
*
|
|
1218
|
-
* @param state - The pattern checkpoint state to inspect.
|
|
1219
|
-
* @returns The current progress count for the pattern.
|
|
1220
|
-
*/
|
|
1221
|
-
declare function getPatternStep(state: PatternCheckpointState): number;
|
|
1222
|
-
/**
|
|
1223
|
-
* Compute progress metrics from a pattern checkpoint state.
|
|
1224
|
-
*
|
|
1225
|
-
* Returns percentage complete, steps completed/remaining, tokens consumed,
|
|
1226
|
-
* and estimated tokens remaining (when computable). Each pattern type
|
|
1227
|
-
* calculates these metrics from its own state structure.
|
|
1228
|
-
*
|
|
1229
|
-
* @param state - The pattern checkpoint state to analyze.
|
|
1230
|
-
* @returns A {@link CheckpointProgress} object with completion metrics.
|
|
1231
|
-
*/
|
|
1232
|
-
declare function getCheckpointProgress(state: PatternCheckpointState): CheckpointProgress;
|
|
1233
|
-
/**
|
|
1234
|
-
* Compute the diff between two checkpoint states of the same pattern type.
|
|
1235
|
-
*
|
|
1236
|
-
* Returns the delta in steps, tokens, and time between checkpoints.
|
|
1237
|
-
* Useful for understanding how much progress occurred between saves.
|
|
1238
|
-
*
|
|
1239
|
-
* @param a - The earlier checkpoint state.
|
|
1240
|
-
* @param b - The later checkpoint state.
|
|
1241
|
-
* @returns A {@link CheckpointDiff} with step, token, and time deltas.
|
|
1242
|
-
* @throws If the two checkpoints have different pattern types.
|
|
1243
|
-
*/
|
|
1244
|
-
declare function diffCheckpoints(a: PatternCheckpointState, b: PatternCheckpointState): CheckpointDiff;
|
|
1245
|
-
/**
|
|
1246
|
-
* Fork an orchestrator from a checkpoint — creates a new independent orchestrator
|
|
1247
|
-
* restored to the checkpoint's state, ready to diverge from that point.
|
|
1248
|
-
*
|
|
1249
|
-
* @param options - The original orchestrator options used to create the orchestrator
|
|
1250
|
-
* @param checkpointStore - The checkpoint store containing the checkpoint
|
|
1251
|
-
* @param checkpointId - The ID of the checkpoint to fork from
|
|
1252
|
-
* @returns A new independent MultiAgentOrchestrator restored to checkpoint state
|
|
1253
|
-
*
|
|
1254
|
-
* @example
|
|
1255
|
-
* ```typescript
|
|
1256
|
-
* const forked = await forkFromCheckpoint(orchestratorOptions, store, "ckpt_abc123");
|
|
1257
|
-
* const result = await forked.replay("ckpt_abc123", pattern, { input: "new input" });
|
|
1258
|
-
* ```
|
|
1259
|
-
*/
|
|
1260
|
-
declare function forkFromCheckpoint(options: MultiAgentOrchestratorOptions, checkpointStore: CheckpointStore, checkpointId: string): Promise<MultiAgentOrchestrator>;
|
|
1261
|
-
/**
|
|
1262
|
-
* Async semaphore for controlling concurrent access.
|
|
1263
|
-
* Uses a queue-based approach instead of polling for efficiency.
|
|
1264
|
-
*
|
|
1265
|
-
* @example
|
|
1266
|
-
* ```typescript
|
|
1267
|
-
* import { Semaphore } from '@directive-run/ai';
|
|
1268
|
-
*
|
|
1269
|
-
* const sem = new Semaphore(3); // Allow 3 concurrent operations
|
|
1270
|
-
*
|
|
1271
|
-
* async function doWork() {
|
|
1272
|
-
* const release = await sem.acquire();
|
|
1273
|
-
* try {
|
|
1274
|
-
* await performWork();
|
|
1275
|
-
* } finally {
|
|
1276
|
-
* release();
|
|
1277
|
-
* }
|
|
1278
|
-
* }
|
|
1279
|
-
* ```
|
|
1280
|
-
*/
|
|
1281
|
-
declare class Semaphore {
|
|
1282
|
-
private count;
|
|
1283
|
-
private readonly maxPermits;
|
|
1284
|
-
private readonly queue;
|
|
1285
|
-
constructor(max: number);
|
|
1286
|
-
/** Create a one-shot release function that guards against double-release */
|
|
1287
|
-
private createReleaseFn;
|
|
1288
|
-
/** Acquire a permit, optionally with abort signal support */
|
|
1289
|
-
acquire(signal?: AbortSignal): Promise<() => void>;
|
|
1290
|
-
/** Non-blocking acquire — returns null if no permits available */
|
|
1291
|
-
tryAcquire(): (() => void) | null;
|
|
1292
|
-
private release;
|
|
1293
|
-
/** Get current available permits */
|
|
1294
|
-
get available(): number;
|
|
1295
|
-
/** Get number of waiters in queue */
|
|
1296
|
-
get waiting(): number;
|
|
1297
|
-
/** Get maximum permits */
|
|
1298
|
-
get max(): number;
|
|
1299
|
-
/** Reject all pending waiters with an error and reset permits */
|
|
1300
|
-
drain(): void;
|
|
1301
|
-
}
|
|
1302
1211
|
/** Configuration for a registered agent */
|
|
1303
1212
|
interface AgentRegistration {
|
|
1304
1213
|
/** The agent instance */
|
|
@@ -1854,53 +1763,8 @@ interface MultiAgentOrchestrator {
|
|
|
1854
1763
|
onDerivedChange(callback: (id: string, value: unknown) => void): () => void;
|
|
1855
1764
|
/** Shared scratchpad (null when not configured) */
|
|
1856
1765
|
readonly scratchpad: Scratchpad | null;
|
|
1857
|
-
/**
|
|
1858
|
-
|
|
1766
|
+
/** Destroy the orchestrator, resetting all state and releasing resources. */
|
|
1767
|
+
destroy(): void;
|
|
1859
1768
|
}
|
|
1860
|
-
/**
|
|
1861
|
-
* Create a multi-agent orchestrator backed by a Directive System.
|
|
1862
|
-
*
|
|
1863
|
-
* Each registered agent becomes a namespaced Directive module with reactive state,
|
|
1864
|
-
* constraint evaluation, guardrails, streaming, approval, memory, retry, budget,
|
|
1865
|
-
* hooks, and time-travel debugging -- all features at parity with {@link createAgentOrchestrator}.
|
|
1866
|
-
*
|
|
1867
|
-
* @param options - Orchestrator configuration including runner, agent registry, patterns, guardrails, and plugins.
|
|
1868
|
-
* @returns A {@link MultiAgentOrchestrator} instance with `runAgent`, `runPattern`, `handoff`, and checkpoint APIs.
|
|
1869
|
-
*
|
|
1870
|
-
* @example
|
|
1871
|
-
* ```typescript
|
|
1872
|
-
* const orchestrator = createMultiAgentOrchestrator({
|
|
1873
|
-
* runner,
|
|
1874
|
-
* agents: {
|
|
1875
|
-
* researcher: { agent: researchAgent, maxConcurrent: 3 },
|
|
1876
|
-
* writer: { agent: writerAgent },
|
|
1877
|
-
* reviewer: { agent: reviewerAgent },
|
|
1878
|
-
* },
|
|
1879
|
-
* guardrails: {
|
|
1880
|
-
* input: [detectPII],
|
|
1881
|
-
* output: [checkToxicity],
|
|
1882
|
-
* },
|
|
1883
|
-
* hooks: {
|
|
1884
|
-
* onAgentStart: ({ agentId, input }) => console.log(`${agentId}: ${input}`),
|
|
1885
|
-
* },
|
|
1886
|
-
* maxTokenBudget: 50000,
|
|
1887
|
-
* debug: true,
|
|
1888
|
-
* });
|
|
1889
|
-
*
|
|
1890
|
-
* // Run with full guardrails + approval + streaming
|
|
1891
|
-
* const result = await orchestrator.runAgent('researcher', 'What is AI?');
|
|
1892
|
-
*
|
|
1893
|
-
* // Stream agent output
|
|
1894
|
-
* const { stream } = orchestrator.runAgentStream('writer', 'Write about AI');
|
|
1895
|
-
* for await (const chunk of stream) {
|
|
1896
|
-
* if (chunk.type === 'token') process.stdout.write(chunk.data);
|
|
1897
|
-
* }
|
|
1898
|
-
* ```
|
|
1899
|
-
*
|
|
1900
|
-
* @throws If a pattern references an agent that is not in the registry
|
|
1901
|
-
* @throws If autoApproveToolCalls is false but no onApprovalRequest callback is provided
|
|
1902
|
-
* @public
|
|
1903
|
-
*/
|
|
1904
|
-
declare function createMultiAgentOrchestrator(options: MultiAgentOrchestratorOptions): MultiAgentOrchestrator;
|
|
1905
1769
|
|
|
1906
|
-
export { type SafeParseResult as $, type AgentRegistry as A, type BackpressureStrategy as B, type
|
|
1770
|
+
export { type SafeParseResult as $, type AgentRegistry as A, type BackpressureStrategy as B, type MessageChunk as C, type DebatePattern as D, type ExecutionPattern as E, type MessageSummarizer as F, type GuardrailTriggeredChunk as G, type HealthMonitor as H, type MultiAgentRunCallOptions as I, type MultiAgentState as J, type MultiplexedStreamChunk as K, type MultiplexedStreamResult as L, type MultiAgentOrchestratorOptions as M, type OrchestratorStreamChunk as N, type OrchestratorOptions as O, type ParallelPattern as P, type OrchestratorStreamResult as Q, type RacePattern as R, type SequentialPattern as S, type ProgressChunk as T, type RaceResult as U, type RaceSuccessEntry as V, type ReflectionConfig as W, type ReflectionContext as X, type ReflectionEvaluator as Y, ReflectionExhaustedError as Z, type RunCallOptions as _, type MultiAgentOrchestrator as a, type SafeParseable as a0, type StreamChunk as a1, type StreamRunOptions as a2, type StreamRunner as a3, type StreamingGuardrail as a4, type StreamingGuardrailResult as a5, type StreamingRunResult as a6, type StructuredOutputConfig as a7, StructuredOutputError as a8, type TaskContext as a9, tapStream as aA, withReflection as aB, withStructuredOutput as aC, type TaskRegistration as aa, type TokenChunk as ab, type ToolEndChunk as ac, type ToolStartChunk as ad, adaptOutputGuardrail as ae, collectTokens as af, combineStreamingGuardrails as ag, createAgentMemory as ah, createAgentOrchestrator as ai, createDebugTimeline as aj, createDebugTimelinePlugin as ak, createHealthMonitor as al, createHybridStrategy as am, createKeyPointsSummarizer as an, createLLMSummarizer as ao, createLengthStreamingGuardrail as ap, createPatternStreamingGuardrail as aq, createSlidingWindowStrategy as ar, createStreamingRunner as as, createTokenBasedStrategy as at, createToxicityStreamingGuardrail as au, createTruncationSummarizer as av, extractJsonFromOutput as aw, filterStream as ax, mapStream as ay, mergeTaggedStreams as az, type ReflectionEvaluation as b, type ReflectIterationRecord as c, type ReflectPattern as d, type SupervisorPattern as e, type RunAgentRequirement as f, type DebateResult as g, type AgentHealthMetrics as h, type DebugTimeline as i, type AgentMemory as j, type AgentMemoryConfig as k, type AgentOrchestrator as l, type AgentRegistration as m, type DebugTimelineListener as n, type DebugTimelineOptions as o, type DoneChunk as p, type ErrorChunk as q, type HandoffRequest as r, type HandoffResult as s, type HealthCircuitState as t, type MemoryManageResult as u, type MemoryState as v, type MemoryStrategy as w, type MemoryStrategyConfig as x, type MemoryStrategyResult as y, type MergedTaggedStreamResult as z };
|
|
@@ -223,20 +223,20 @@ declare function createSemanticCacheGuardrail(config: {
|
|
|
223
223
|
* NOT suitable for production - use a real embedding model.
|
|
224
224
|
*/
|
|
225
225
|
declare function createTestEmbedder(dimensions?: number): EmbedderFn;
|
|
226
|
-
/** Batched embedder instance with
|
|
226
|
+
/** Batched embedder instance with destroy capability */
|
|
227
227
|
interface BatchedEmbedder {
|
|
228
228
|
/** Embed a single text (batched internally) */
|
|
229
229
|
embed: EmbedderFn;
|
|
230
230
|
/** Flush any pending batch immediately */
|
|
231
231
|
flush(): Promise<void>;
|
|
232
|
-
/**
|
|
233
|
-
|
|
232
|
+
/** Destroy the embedder, clearing timers and rejecting pending requests */
|
|
233
|
+
destroy(): void;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Create a batched embedder that groups multiple texts into single API calls.
|
|
237
237
|
*
|
|
238
238
|
* **BREAKING CHANGE:** Previously returned `EmbedderFn` directly. Now returns
|
|
239
|
-
* a `BatchedEmbedder` object with `embed`, `flush`, and `
|
|
239
|
+
* a `BatchedEmbedder` object with `embed`, `flush`, and `destroy` methods.
|
|
240
240
|
*
|
|
241
241
|
* To migrate: `const embed = createBatchedEmbedder(...)` becomes
|
|
242
242
|
* `const { embed } = createBatchedEmbedder(...)`.
|
|
@@ -259,7 +259,7 @@ interface BatchedEmbedder {
|
|
|
259
259
|
* const embedding = await batchedEmbedder.embed("Hello world");
|
|
260
260
|
*
|
|
261
261
|
* // Clean up when done
|
|
262
|
-
* batchedEmbedder.
|
|
262
|
+
* batchedEmbedder.destroy();
|
|
263
263
|
* ```
|
|
264
264
|
*/
|
|
265
265
|
declare function createBatchedEmbedder(config: {
|
|
@@ -223,20 +223,20 @@ declare function createSemanticCacheGuardrail(config: {
|
|
|
223
223
|
* NOT suitable for production - use a real embedding model.
|
|
224
224
|
*/
|
|
225
225
|
declare function createTestEmbedder(dimensions?: number): EmbedderFn;
|
|
226
|
-
/** Batched embedder instance with
|
|
226
|
+
/** Batched embedder instance with destroy capability */
|
|
227
227
|
interface BatchedEmbedder {
|
|
228
228
|
/** Embed a single text (batched internally) */
|
|
229
229
|
embed: EmbedderFn;
|
|
230
230
|
/** Flush any pending batch immediately */
|
|
231
231
|
flush(): Promise<void>;
|
|
232
|
-
/**
|
|
233
|
-
|
|
232
|
+
/** Destroy the embedder, clearing timers and rejecting pending requests */
|
|
233
|
+
destroy(): void;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Create a batched embedder that groups multiple texts into single API calls.
|
|
237
237
|
*
|
|
238
238
|
* **BREAKING CHANGE:** Previously returned `EmbedderFn` directly. Now returns
|
|
239
|
-
* a `BatchedEmbedder` object with `embed`, `flush`, and `
|
|
239
|
+
* a `BatchedEmbedder` object with `embed`, `flush`, and `destroy` methods.
|
|
240
240
|
*
|
|
241
241
|
* To migrate: `const embed = createBatchedEmbedder(...)` becomes
|
|
242
242
|
* `const { embed } = createBatchedEmbedder(...)`.
|
|
@@ -259,7 +259,7 @@ interface BatchedEmbedder {
|
|
|
259
259
|
* const embedding = await batchedEmbedder.embed("Hello world");
|
|
260
260
|
*
|
|
261
261
|
* // Clean up when done
|
|
262
|
-
* batchedEmbedder.
|
|
262
|
+
* batchedEmbedder.destroy();
|
|
263
263
|
* ```
|
|
264
264
|
*/
|
|
265
265
|
declare function createBatchedEmbedder(config: {
|