@fevex/core 0.1.0-alpha.11 → 0.1.0-alpha.12

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.
Files changed (34) hide show
  1. package/README.md +89 -14
  2. package/dist/agents/index.d.mts +1 -1
  3. package/dist/artifacts/index.d.mts +1 -1
  4. package/dist/channels/index.d.mts +1 -1
  5. package/dist/evals/index.d.mts +198 -5
  6. package/dist/evals/index.mjs +478 -12
  7. package/dist/{fevex-_KOsOsB8.d.mts → fevex-B4eNkGTa.d.mts} +19 -10
  8. package/dist/http/index.d.mts +4 -4
  9. package/dist/{index-DHcfIfh-.d.mts → index-AOouohIx.d.mts} +3 -3
  10. package/dist/{index-B8EcvWeN.d.mts → index-AVlWktA8.d.mts} +3 -3
  11. package/dist/{index-BEqYWean.d.mts → index-B7fxPgn_.d.mts} +5 -5
  12. package/dist/{index-Btth7rdL.d.mts → index-CAVMQT9j.d.mts} +3 -3
  13. package/dist/{index-D7r0puBi.d.mts → index-Cbe1ZiyN.d.mts} +1 -1
  14. package/dist/{index-CIHWc5V1.d.mts → index-D1LAhzgC.d.mts} +2 -2
  15. package/dist/{index-26ilbzAs.d.mts → index-DMmrhb8l.d.mts} +4 -4
  16. package/dist/index-KKq-_SiK.d.mts +43 -0
  17. package/dist/{index-lCCFokc6.d.mts → index-giFR5t0x.d.mts} +5 -3
  18. package/dist/{index-DUhNa7IR.d.mts → index-k-gBmfJP.d.mts} +1 -1
  19. package/dist/index.d.mts +13 -13
  20. package/dist/index.mjs +214 -31
  21. package/dist/knowledge/index.d.mts +1 -1
  22. package/dist/models/index.d.mts +1 -1
  23. package/dist/observability/index.d.mts +1 -1
  24. package/dist/policies/index.d.mts +2 -2
  25. package/dist/policies/index.mjs +39 -1
  26. package/dist/runtime/index.d.mts +1 -1
  27. package/dist/sandbox/index.d.mts +1 -1
  28. package/dist/teams/index.d.mts +1 -1
  29. package/dist/testing/index.d.mts +6 -6
  30. package/dist/tools/index.d.mts +2 -2
  31. package/dist/{types-CckDlhYo.d.mts → types-B6hD1o2I.d.mts} +19 -1
  32. package/dist/workflows/index.d.mts +1 -1
  33. package/package.json +1 -1
  34. package/dist/index-CFzrvDQ0.d.mts +0 -21
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import { FEVEX_JSON_SCHEMA_PROFILE_VERSION, InMemoryToolEmbeddingCache, Integrat
9
9
  import { _ as serializeValue, a as assertTokenBudget, c as eventUsage, d as remainingDeadlineMs, f as remainingOutputTokens, g as serializeJsonValue, h as toErrorMessage, i as assertContinuationBudget, l as isTimeoutError, m as runSignal, n as abortable, o as cancellationReason, p as resumeDeadlineSignal, r as addUsage, s as deadlineAtFromMs, u as minDeadline, v as toJsonValue } from "./run-support-CmZ6Xo6H.mjs";
10
10
  import { t as readModelStream } from "./model-stream-JQdHDDcj.mjs";
11
11
  import "./models/index.mjs";
12
- import { definePolicy } from "./policies/index.mjs";
12
+ import { definePolicy, riskGuardrail } from "./policies/index.mjs";
13
13
  import { SandboxError, createLocalSandbox, sandboxResultToJson } from "./sandbox/index.mjs";
14
14
  import { defineWorkflow } from "./workflows/index.mjs";
15
15
  //#region src/configuration-error.ts
@@ -930,21 +930,37 @@ function systemBlock(label, provider, block) {
930
930
  };
931
931
  }
932
932
  async function readMemoryMessages(agent, context, memoryStore) {
933
- if (!agent.memory || agent.memory.read === false || !memoryStore) return [];
933
+ if (!agent.memory || agent.memory.read === false || !memoryStore) return { messages: [] };
934
+ const startedAt = performance.now();
934
935
  try {
935
- return (await abortable(() => memoryStore.search({
936
+ const records = await abortable(() => memoryStore.search({
936
937
  query: context.input,
937
938
  limit: agent.memory?.limit ?? 5,
938
939
  agentName: context.agentName,
939
940
  sessionId: context.sessionId,
940
941
  namespace: context.context?.namespace,
941
942
  actor: context.context?.actor
942
- }, context), context.signal)).filter((record) => record.content.trim()).map((record) => ({
943
- role: "system",
944
- content: `[Memory: ${record.id}]\n${record.content}`
945
- }));
943
+ }, context), context.signal);
944
+ return {
945
+ messages: records.filter((record) => record.content.trim()).map((record) => ({
946
+ role: "system",
947
+ content: `[Memory: ${record.id}]\n${record.content}`
948
+ })),
949
+ trace: {
950
+ durationMs: performance.now() - startedAt,
951
+ recordCount: records.length
952
+ }
953
+ };
946
954
  } catch (cause) {
947
- throw new Error("Memory search failed", { cause });
955
+ const error = cause instanceof Error ? cause.message : String(cause);
956
+ return {
957
+ messages: [],
958
+ trace: {
959
+ durationMs: performance.now() - startedAt,
960
+ error
961
+ },
962
+ error: cause
963
+ };
948
964
  }
949
965
  }
950
966
  const toolSourcePayload = (tool, error) => {
@@ -1384,7 +1400,6 @@ function createAgentEngine(composition, core) {
1384
1400
  ...knowledge.skills,
1385
1401
  ...sessionHistoryMessages(session),
1386
1402
  ...knowledge.context,
1387
- ...knowledge.memory,
1388
1403
  {
1389
1404
  role: "user",
1390
1405
  content: inputContent
@@ -1419,18 +1434,18 @@ function createAgentEngine(composition, core) {
1419
1434
  ownerId,
1420
1435
  expiresAt: new Date(Date.now() + LEASE_MS).toISOString()
1421
1436
  };
1422
- const started = createEvent(state, "run.started", void 0);
1437
+ const initialEvents = [createEvent(state, "run.started", void 0)];
1423
1438
  if (!await runStore.createExecution({
1424
1439
  run,
1425
1440
  checkpoint,
1426
1441
  session,
1427
1442
  lease,
1428
- events: [started]
1443
+ events: initialEvents
1429
1444
  })) throw new FevexRunError("RUN_CONFLICT", `Run or session "${session.id}" is active or was modified`, run.id);
1430
1445
  state.checkpoint = checkpoint;
1431
1446
  state.lease = lease;
1432
- state.initialEvents = [started];
1433
- notifyObserver(started);
1447
+ state.initialEvents = initialEvents;
1448
+ for (const event of initialEvents) notifyObserver(event);
1434
1449
  startLease(state, runStore);
1435
1450
  } else {
1436
1451
  if (newSession) await runStore.saveSession(session);
@@ -1476,6 +1491,7 @@ function createAgentEngine(composition, core) {
1476
1491
  loadedTools: [...state.loadedTools ?? []],
1477
1492
  messages: structuredClone(messages),
1478
1493
  inputContent,
1494
+ ...state.checkpoint?.memoryLoaded === void 0 ? {} : { memoryLoaded: state.checkpoint.memoryLoaded },
1479
1495
  context: state.request.context,
1480
1496
  usage,
1481
1497
  providerState: serializedState,
@@ -1508,25 +1524,38 @@ function createAgentEngine(composition, core) {
1508
1524
  const context = knowledgeContext(state, input);
1509
1525
  return {
1510
1526
  skills: (await Promise.all((agent.skills ?? []).map((name) => readProvider(name, "Skill", context)))).flat(),
1511
- context: (await Promise.all((agent.context ?? []).map((name) => readProvider(name, "Context", context)))).flat(),
1512
- memory: await readMemoryMessages(agent, context, memoryStore)
1527
+ context: (await Promise.all((agent.context ?? []).map((name) => readProvider(name, "Context", context)))).flat()
1513
1528
  };
1514
1529
  };
1515
- const writeMemory = async (state, agent, input, output) => {
1530
+ const writeMemory = async (state, agent, input, output, emit) => {
1516
1531
  if (!agent.memory?.write || !memoryStore) return;
1517
1532
  const context = knowledgeContext(state, input);
1533
+ const startedAt = performance.now();
1534
+ let recordId;
1518
1535
  try {
1519
- await abortable(() => memoryStore.write({
1536
+ recordId = (await abortable(() => memoryStore.write({
1520
1537
  content: `User: ${input}\nAssistant: ${serializeJsonValue(output)}`,
1521
1538
  agentName: state.run.agentName,
1522
1539
  sessionId: state.session.id,
1523
1540
  namespace: state.request.context?.namespace,
1524
1541
  actor: state.request.context?.actor,
1525
1542
  metadata: { runId: state.run.id }
1526
- }, context), state.request.signal);
1543
+ }, context), state.request.signal)).id;
1527
1544
  } catch (cause) {
1545
+ const error = cause instanceof Error ? cause.message : String(cause);
1546
+ await emit("memory.completed", {
1547
+ operation: "write",
1548
+ durationMs: performance.now() - startedAt,
1549
+ error
1550
+ }).catch(() => {});
1528
1551
  throw new Error("Memory write failed", { cause });
1529
1552
  }
1553
+ await emit("memory.completed", {
1554
+ operation: "write",
1555
+ durationMs: performance.now() - startedAt,
1556
+ recordCount: 1,
1557
+ ...recordId === void 0 ? {} : { recordId }
1558
+ });
1530
1559
  };
1531
1560
  async function* executeAgent(name, state) {
1532
1561
  const { request } = state;
@@ -1589,7 +1618,6 @@ function createAgentEngine(composition, core) {
1589
1618
  ...knowledge.skills,
1590
1619
  ...sessionHistoryMessages(state.session),
1591
1620
  ...knowledge.context,
1592
- ...knowledge.memory,
1593
1621
  {
1594
1622
  role: "user",
1595
1623
  content: inputContent
@@ -1601,6 +1629,21 @@ function createAgentEngine(composition, core) {
1601
1629
  pendingTools = [];
1602
1630
  pendingIndex = 0;
1603
1631
  }
1632
+ if (!(state.checkpoint?.memoryLoaded ?? messages.some((message, index) => index > 0 && message.role === "system" && message.content.startsWith("[Memory: "))) && agent.memory && agent.memory.read !== false && memoryStore) {
1633
+ const memory = await readMemoryMessages(agent, knowledgeContext(state, inputContent), memoryStore);
1634
+ if (memory.trace) yield await emit("memory.completed", {
1635
+ operation: "search",
1636
+ durationMs: memory.trace.durationMs,
1637
+ ...memory.trace.recordCount === void 0 ? {} : { recordCount: memory.trace.recordCount },
1638
+ ...memory.trace.error === void 0 ? {} : { error: memory.trace.error }
1639
+ });
1640
+ if (memory.error !== void 0) throw new Error("Memory search failed", { cause: memory.error });
1641
+ if (memory.messages.length) messages.splice(Math.max(0, messages.length - 1), 0, ...memory.messages);
1642
+ if (state.checkpoint) {
1643
+ state.checkpoint.memoryLoaded = true;
1644
+ await commit(state, { checkpoint: state.checkpoint });
1645
+ }
1646
+ }
1604
1647
  const activeOutputSchema = agent.outputSchema;
1605
1648
  const outputSchema = activeOutputSchema === void 0 ? void 0 : toTransportableSchema(activeOutputSchema, "output", `Output schema for agent "${name}" is not transportable`);
1606
1649
  const currentElicitationMode = state.checkpoint?.effectiveElicitationMode ?? effectiveElicitationMode(agent, request);
@@ -1818,7 +1861,7 @@ function createAgentEngine(composition, core) {
1818
1861
  if (!result.toolCalls?.length) {
1819
1862
  if (result.output === void 0) throw new Error(`Model for agent "${name}" returned no output`);
1820
1863
  const output = toJsonValue(activeOutputSchema === void 0 ? result.output : await abortable(() => validateSchema(activeOutputSchema, result.output, `Output from agent "${name}" does not match outputSchema`), request.signal), `Output from agent "${name}" must be JSON-serializable`);
1821
- await writeMemory(state, agent, inputContent, output);
1864
+ await writeMemory(state, agent, inputContent, output, emit);
1822
1865
  state.session.history.push({
1823
1866
  role: "user",
1824
1867
  content: inputContent
@@ -1884,7 +1927,9 @@ function createAgentEngine(composition, core) {
1884
1927
  yield await emit("tool.started", {
1885
1928
  step,
1886
1929
  toolCallId: internalCall.id,
1887
- toolName: internalCall.name
1930
+ toolName: internalCall.name,
1931
+ risk: "read",
1932
+ declaredRisk: "read"
1888
1933
  });
1889
1934
  let execution;
1890
1935
  try {
@@ -2022,7 +2067,7 @@ function createAgentEngine(composition, core) {
2022
2067
  const durable = isDurableRunStore(runStore) ? runStore : void 0;
2023
2068
  if (!durable && (tool.approval === "required" || tool.idempotency === "keyed")) throw new FevexRunError("DURABLE_STORE_REQUIRED", `Tool "${tool.name}" requires a DurableRunStore`, state.run.id);
2024
2069
  let record = durable ? await durable.getToolExecution(state.run.id, pending.call.id) : void 0;
2025
- const policy = await authorize(state, tool, pending.input, "tool.execute");
2070
+ const policy = await authorize(state, tool, pending.input, "tool.execute", state.request.context, pending.call.id);
2026
2071
  if ((tool.approval === "required" || policy === "require_approval") && state.approvedToolCallId !== pending.call.id && record?.status !== "started" && record?.status !== "completed") {
2027
2072
  if (currentApprovalMode === "deny") throw new FevexRunError("POLICY_DENIED", `Tool "${tool.name}" requires approval but approvalMode is "deny"`, state.run.id);
2028
2073
  const checkpoint = await durableCheckpoint(state, model, modelName, messages, inputContent, usage, providerState, step, toolCallCount, seenToolCallIds, pendingTools, pendingIndex);
@@ -2115,7 +2160,7 @@ function createAgentEngine(composition, core) {
2115
2160
  let attempt = record?.status === "started" && tool.idempotency === "keyed" ? Math.max(0, record.attempt - 1) : record?.attempt ?? 0;
2116
2161
  while (attempt < maxAttempts) {
2117
2162
  if (attempt > 0) {
2118
- if (await authorize(state, tool, pending.input, "tool.execute") === "require_approval") {
2163
+ if (await authorize(state, tool, pending.input, "tool.execute", state.request.context, pending.call.id) === "require_approval") {
2119
2164
  if (currentApprovalMode === "deny") throw new FevexRunError("POLICY_DENIED", `Tool "${tool.name}" requires approval but approvalMode is "deny"`, state.run.id);
2120
2165
  const checkpoint = await durableCheckpoint(state, model, modelName, messages, inputContent, usage, providerState, step, toolCallCount, seenToolCallIds, pendingTools, pendingIndex);
2121
2166
  const approval = {
@@ -2199,6 +2244,8 @@ function createAgentEngine(composition, core) {
2199
2244
  step,
2200
2245
  toolCallId: pending.call.id,
2201
2246
  toolName: pending.call.name,
2247
+ risk: tool.risk ?? "read",
2248
+ ...tool.risk === void 0 ? {} : { declaredRisk: tool.risk },
2202
2249
  ...toolSourcePayload(tool),
2203
2250
  ...attempt > 1 ? { attempt } : {}
2204
2251
  });
@@ -2518,7 +2565,7 @@ function createAgentEngine(composition, core) {
2518
2565
  if (resolution.decision === "approve") await authorize(state, tool, pending.input, "approval.resolve", {
2519
2566
  ...state.request.context,
2520
2567
  actor: resolution.actor
2521
- });
2568
+ }, pending.call.id);
2522
2569
  if (resolution.decision === "reject") {
2523
2570
  const approval = run.pause.approval;
2524
2571
  const toolCallId = approval.toolCallId;
@@ -2857,6 +2904,19 @@ function annotation(event) {
2857
2904
  delayMs: event.payload.delayMs
2858
2905
  }
2859
2906
  };
2907
+ case "policy.evaluated": return {
2908
+ name: event.type,
2909
+ timestamp: event.timestamp,
2910
+ attributes: {
2911
+ policyName: event.payload.policyName,
2912
+ toolName: event.payload.toolName,
2913
+ ...event.payload.toolCallId === void 0 ? {} : { toolCallId: event.payload.toolCallId },
2914
+ action: event.payload.action,
2915
+ decision: event.payload.decision,
2916
+ risk: event.payload.risk,
2917
+ ...event.payload.declaredRisk === void 0 ? {} : { declaredRisk: event.payload.declaredRisk }
2918
+ }
2919
+ };
2860
2920
  case "context.compacted": return {
2861
2921
  name: event.type,
2862
2922
  timestamp: event.timestamp,
@@ -3005,6 +3065,8 @@ function buildAgentTrace(run, events, modelRegistryName, model, options) {
3005
3065
  step: event.payload.step,
3006
3066
  toolCallId,
3007
3067
  toolName: event.payload.toolName,
3068
+ risk: event.payload.risk ?? "read",
3069
+ ...event.payload.declaredRisk === void 0 ? {} : { declaredRisk: event.payload.declaredRisk },
3008
3070
  attempt: event.payload.attempt ?? 1
3009
3071
  },
3010
3072
  annotations: open.annotations,
@@ -3028,6 +3090,29 @@ function buildAgentTrace(run, events, modelRegistryName, model, options) {
3028
3090
  case "model.completed":
3029
3091
  closeModel(event.payload.step, event.timestamp, "completed");
3030
3092
  break;
3093
+ case "memory.completed": {
3094
+ const endedAt = Date.parse(event.timestamp);
3095
+ const startedAt = new Date(endedAt - Math.max(0, event.payload.durationMs)).toISOString();
3096
+ const errorContent = event.payload.error ? content(options, "error.message", event.payload.error) : void 0;
3097
+ spans.push({
3098
+ id: event.id,
3099
+ parentId: run.id,
3100
+ kind: "memory",
3101
+ name: event.payload.operation === "search" ? "search_memory" : "create_memory",
3102
+ startedAt,
3103
+ endedAt: event.timestamp,
3104
+ durationMs: Math.max(0, event.payload.durationMs),
3105
+ status: event.payload.error ? "failed" : "completed",
3106
+ attributes: {
3107
+ operation: event.payload.operation,
3108
+ ...event.payload.recordCount === void 0 ? {} : { recordCount: event.payload.recordCount },
3109
+ ...event.payload.recordId === void 0 ? {} : { recordId: event.payload.recordId }
3110
+ },
3111
+ annotations: [],
3112
+ ...errorContent ? { content: [errorContent] } : {}
3113
+ });
3114
+ break;
3115
+ }
3031
3116
  case "tool.started": {
3032
3117
  const attempt = event.payload.attempt ?? 1;
3033
3118
  openTools.set(`${event.payload.toolCallId}:${attempt}`, {
@@ -3060,6 +3145,8 @@ function buildAgentTrace(run, events, modelRegistryName, model, options) {
3060
3145
  const finalUsage = run.usage ?? previousUsage;
3061
3146
  const totalCost = costFor(options, modelRegistryName, model, finalUsage);
3062
3147
  const traceContent = terminalContent(options, terminal);
3148
+ const startedAtMs = Math.min(Date.parse(started.timestamp), ...spans.filter(({ kind }) => kind === "memory").map(({ startedAt }) => Date.parse(startedAt)));
3149
+ const traceStartedAt = new Date(startedAtMs).toISOString();
3063
3150
  return {
3064
3151
  schemaVersion: "1",
3065
3152
  kind: "agent",
@@ -3071,14 +3158,15 @@ function buildAgentTrace(run, events, modelRegistryName, model, options) {
3071
3158
  agentName: run.agentName,
3072
3159
  modelRegistryName,
3073
3160
  ...model ? { model: { ...model } } : {},
3074
- startedAt: started.timestamp,
3161
+ startedAt: traceStartedAt,
3075
3162
  endedAt: terminal.timestamp,
3076
- durationMs: durationMs(started.timestamp, terminal.timestamp),
3163
+ durationMs: durationMs(traceStartedAt, terminal.timestamp),
3077
3164
  status,
3078
3165
  attributes: {
3079
3166
  eventCount: events.length,
3080
3167
  modelCallCount: spans.filter(({ kind }) => kind === "model").length,
3081
- toolCallCount: spans.filter(({ kind }) => kind === "tool").length
3168
+ toolCallCount: spans.filter(({ kind }) => kind === "tool").length,
3169
+ memoryOperationCount: spans.filter(({ kind }) => kind === "memory").length
3082
3170
  },
3083
3171
  annotations,
3084
3172
  spans,
@@ -3376,6 +3464,7 @@ function createRunCore({ models, agents, tools, runStore, policies, onEvent, obs
3376
3464
  "elicitation.resolved",
3377
3465
  "approval.requested",
3378
3466
  "approval.resolved",
3467
+ "policy.evaluated",
3379
3468
  "tool.execution_unknown",
3380
3469
  "run.completed",
3381
3470
  "run.failed",
@@ -3640,18 +3729,30 @@ function createRunCore({ models, agents, tools, runStore, policies, onEvent, obs
3640
3729
  });
3641
3730
  await state.commitQueue;
3642
3731
  };
3643
- const authorize = async (state, tool, input, action, context = state.request.context) => {
3732
+ const authorize = async (state, tool, input, action, context = state.request.context, toolCallId) => {
3644
3733
  let approval = false;
3645
3734
  for (const policy of policies) {
3735
+ const risk = tool.risk ?? "read";
3736
+ const declaredRisk = tool.risk;
3646
3737
  const decision = await policy.authorize({
3647
3738
  runId: state.run.id,
3648
3739
  agentName: state.run.agentName,
3649
3740
  toolName: tool.name,
3650
- risk: tool.risk ?? "read",
3741
+ risk,
3742
+ ...declaredRisk === void 0 ? {} : { declaredRisk },
3651
3743
  input,
3652
3744
  action,
3653
3745
  context
3654
3746
  });
3747
+ await emitEvent(state, "policy.evaluated", {
3748
+ policyName: policy.name,
3749
+ toolName: tool.name,
3750
+ ...toolCallId === void 0 ? {} : { toolCallId },
3751
+ action,
3752
+ decision,
3753
+ risk,
3754
+ ...declaredRisk === void 0 ? {} : { declaredRisk }
3755
+ });
3655
3756
  if (decision === "deny") throw new FevexRunError("POLICY_DENIED", `Policy "${policy.name}" denied tool "${tool.name}"`, state.run.id);
3656
3757
  if (decision === "require_approval") approval = true;
3657
3758
  }
@@ -4797,9 +4898,37 @@ function createWorkflowEngine(composition, core, agentEngine) {
4797
4898
  //#region src/internal/runtime.ts
4798
4899
  const DEFAULT_SHUTDOWN_TIMEOUT_MS = 3e4;
4799
4900
  const SHUTDOWN_CLEANUP_MS = 5e3;
4901
+ const RUN_WAIT_EVENT_TYPES = /* @__PURE__ */ new Set([
4902
+ "run.paused",
4903
+ "run.completed",
4904
+ "run.failed",
4905
+ "run.cancelled",
4906
+ "workflow.run.paused",
4907
+ "workflow.run.completed",
4908
+ "workflow.run.failed",
4909
+ "workflow.run.cancelled",
4910
+ "team.run.paused",
4911
+ "team.run.completed",
4912
+ "team.run.failed",
4913
+ "team.run.cancelled"
4914
+ ]);
4800
4915
  function createRuntime(composition) {
4801
4916
  const { models, agents, workflows, teams, tools, contextProviders, memoryStore, runStore, credentialStore, sandbox, policies } = composition;
4802
- const core = createRunCore(composition);
4917
+ const runWaiters = /* @__PURE__ */ new Map();
4918
+ const wakeRunWaiters = (event) => {
4919
+ if (!RUN_WAIT_EVENT_TYPES.has(event.type)) return;
4920
+ const waiters = runWaiters.get(event.runId);
4921
+ if (!waiters) return;
4922
+ for (const wake of [...waiters]) wake();
4923
+ };
4924
+ const userOnEvent = composition.onEvent;
4925
+ const core = createRunCore({
4926
+ ...composition,
4927
+ onEvent(event) {
4928
+ wakeRunWaiters(event);
4929
+ return userOnEvent?.(event);
4930
+ }
4931
+ });
4803
4932
  const { activeRuns, activeWorkflowRuns, activeSessions, isIdle, waitForIdle, closeAdmission, isClosed, traceExports, runtimeOwner, createEvent, createCoordinatorEvent, notifyObserver, commit, startLease, cancelExecution, releaseWorkflowExecution, commitWorkflow } = core;
4804
4933
  const agentEngine = createAgentEngine(composition, core);
4805
4934
  const { prepareExecution, executeAgent, nextEvent, drainExecution, resumeAgent, cancelStoredAgent, getCompactionStats } = agentEngine;
@@ -4817,6 +4946,57 @@ function createRuntime(composition) {
4817
4946
  if (isCoordinatorRun(run)) return resumeWorkflow(runId, void 0, actor);
4818
4947
  return resumeAgent(runId, void 0, false, actor);
4819
4948
  };
4949
+ const waitForRun = async (runId, options = {}) => {
4950
+ if (options.timeoutMs !== void 0 && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 0)) throw new TypeError("waitForRun timeoutMs must be a non-negative safe integer");
4951
+ const current = await runStore.getRun(runId);
4952
+ if (!current || current.status !== "running") return current;
4953
+ const signal = options.signal;
4954
+ signal?.throwIfAborted();
4955
+ return new Promise((resolve, reject) => {
4956
+ let settled = false;
4957
+ let timer;
4958
+ const wake = () => {
4959
+ if (settled) return;
4960
+ runStore.getRun(runId).then((run) => {
4961
+ if (!run || run.status !== "running") settle(run);
4962
+ }, (error) => settle(void 0, error));
4963
+ };
4964
+ const cleanup = () => {
4965
+ const waiters = runWaiters.get(runId);
4966
+ waiters?.delete(wake);
4967
+ if (waiters && waiters.size === 0) runWaiters.delete(runId);
4968
+ if (timer !== void 0) clearTimeout(timer);
4969
+ signal?.removeEventListener("abort", onAbort);
4970
+ };
4971
+ const settle = (run, error) => {
4972
+ if (settled) return;
4973
+ settled = true;
4974
+ cleanup();
4975
+ if (error === void 0) resolve(run);
4976
+ else reject(error);
4977
+ };
4978
+ const onAbort = () => {
4979
+ settle(void 0, signal?.reason ?? new DOMException("Aborted", "AbortError"));
4980
+ };
4981
+ let waiters = runWaiters.get(runId);
4982
+ if (!waiters) {
4983
+ waiters = /* @__PURE__ */ new Set();
4984
+ runWaiters.set(runId, waiters);
4985
+ }
4986
+ waiters.add(wake);
4987
+ if (signal) {
4988
+ if (signal.aborted) {
4989
+ onAbort();
4990
+ return;
4991
+ }
4992
+ signal.addEventListener("abort", onAbort, { once: true });
4993
+ }
4994
+ if (options.timeoutMs !== void 0) timer = setTimeout(() => {
4995
+ settle(void 0, new FevexRunError("RUN_WAIT_TIMEOUT", `Run "${runId}" did not leave the running state within ${options.timeoutMs}ms`, runId));
4996
+ }, options.timeoutMs);
4997
+ wake();
4998
+ });
4999
+ };
4820
5000
  const waitForIdleUntil = async (deadline) => {
4821
5001
  if (isIdle()) return true;
4822
5002
  const remaining = deadline - Date.now();
@@ -4955,6 +5135,9 @@ function createRuntime(composition) {
4955
5135
  getRun(runId) {
4956
5136
  return runStore.getRun(runId);
4957
5137
  },
5138
+ waitForRun(runId, options) {
5139
+ return waitForRun(runId, options);
5140
+ },
4958
5141
  listEvents(runId, options) {
4959
5142
  return runStore.listEvents(runId, options);
4960
5143
  },
@@ -5024,4 +5207,4 @@ function createFevex(config) {
5024
5207
  return createRuntime(createComposition(config));
5025
5208
  }
5026
5209
  //#endregion
5027
- export { ArtifactError, CatalogedArtifactStore, ChannelError, FEVEX_JSON_SCHEMA_PROFILE_VERSION, FevexConfigurationError, FevexRunError, FileSystemArtifactStore, InMemoryArtifactCatalog, InMemoryArtifactStore, InMemoryMemoryStore, InMemoryRunStore, InMemoryToolEmbeddingCache, IntegrationError, PROVIDER_REASONING_UNSUPPORTED, PROVIDER_SCHEMA_UNSUPPORTED, RunPausedError, S3ArtifactStore, SCHEMA_NOT_TRANSPORTABLE, SandboxError, artifactTenantId, assertArtifactId, buildToolEmbeddingIndex, compileFevexJsonSchema, cosineSimilarity, createAgentsMdContextProvider, createDigestContextCompactor, createFevex, createLocalSandbox, createMemoryContextProvider, createModelContextCompactor, defineAgent, defineConnection, defineContextProvider, definePolicy, defineSkill, defineTeam, defineTool, defineWorkflow, deliverChannelRun, estimateContextTokens, handleChannelInput, isDurableRunStore, isProgressiveSkillProvider, isRetainableRunStore, loadSkillFile, loadSkillFiles, resolveContextBudget, sandboxResultToJson, schemaKeywords, searchToolEmbeddingIndex, toToolSpec, toolEmbeddingKey, toolEmbeddingText, validateFevexJsonSchemaProfile, validateListEventsOptions, validatePurgeRunsOptions };
5210
+ export { ArtifactError, CatalogedArtifactStore, ChannelError, FEVEX_JSON_SCHEMA_PROFILE_VERSION, FevexConfigurationError, FevexRunError, FileSystemArtifactStore, InMemoryArtifactCatalog, InMemoryArtifactStore, InMemoryMemoryStore, InMemoryRunStore, InMemoryToolEmbeddingCache, IntegrationError, PROVIDER_REASONING_UNSUPPORTED, PROVIDER_SCHEMA_UNSUPPORTED, RunPausedError, S3ArtifactStore, SCHEMA_NOT_TRANSPORTABLE, SandboxError, artifactTenantId, assertArtifactId, buildToolEmbeddingIndex, compileFevexJsonSchema, cosineSimilarity, createAgentsMdContextProvider, createDigestContextCompactor, createFevex, createLocalSandbox, createMemoryContextProvider, createModelContextCompactor, defineAgent, defineConnection, defineContextProvider, definePolicy, defineSkill, defineTeam, defineTool, defineWorkflow, deliverChannelRun, estimateContextTokens, handleChannelInput, isDurableRunStore, isProgressiveSkillProvider, isRetainableRunStore, loadSkillFile, loadSkillFiles, resolveContextBudget, riskGuardrail, sandboxResultToJson, schemaKeywords, searchToolEmbeddingIndex, toToolSpec, toolEmbeddingKey, toolEmbeddingText, validateFevexJsonSchemaProfile, validateListEventsOptions, validatePurgeRunsOptions };
@@ -1,2 +1,2 @@
1
- import { _ as defineContextProvider, a as AgentsMdOptions, c as ContextProvider, d as MemoryRecord, f as MemoryStore, g as createMemoryContextProvider, h as SkillDefinition, i as InMemoryMemoryStore, l as KnowledgeContext, m as ProgressiveSkillProvider, n as loadSkillFile, o as createAgentsMdContextProvider, p as MemoryWrite, r as loadSkillFiles, s as ContextBlock, t as LoadSkillFileOptions, u as MemoryQuery, v as defineSkill, y as isProgressiveSkillProvider } from "../index-CIHWc5V1.mjs";
1
+ import { _ as defineContextProvider, a as AgentsMdOptions, c as ContextProvider, d as MemoryRecord, f as MemoryStore, g as createMemoryContextProvider, h as SkillDefinition, i as InMemoryMemoryStore, l as KnowledgeContext, m as ProgressiveSkillProvider, n as loadSkillFile, o as createAgentsMdContextProvider, p as MemoryWrite, r as loadSkillFiles, s as ContextBlock, t as LoadSkillFileOptions, u as MemoryQuery, v as defineSkill, y as isProgressiveSkillProvider } from "../index-D1LAhzgC.mjs";
2
2
  export { AgentsMdOptions, ContextBlock, ContextProvider, InMemoryMemoryStore, KnowledgeContext, LoadSkillFileOptions, MemoryQuery, MemoryRecord, MemoryStore, MemoryWrite, ProgressiveSkillProvider, SkillDefinition, createAgentsMdContextProvider, createMemoryContextProvider, defineContextProvider, defineSkill, isProgressiveSkillProvider, loadSkillFile, loadSkillFiles };
@@ -1,2 +1,2 @@
1
- import { a as ModelResult, c as ReasoningEffort, i as ModelRef, l as ToolChoice, n as ModelInput, o as ModelStreamEvent, r as ModelMetadata, s as ModelUsage, t as ModelGateway, u as EmbeddingModel } from "../index-D7r0puBi.mjs";
1
+ import { a as ModelResult, c as ReasoningEffort, i as ModelRef, l as ToolChoice, n as ModelInput, o as ModelStreamEvent, r as ModelMetadata, s as ModelUsage, t as ModelGateway, u as EmbeddingModel } from "../index-Cbe1ZiyN.mjs";
2
2
  export { EmbeddingModel, ModelGateway, ModelInput, ModelMetadata, ModelRef, ModelResult, ModelStreamEvent, ModelUsage, ReasoningEffort, ToolChoice };
@@ -1,2 +1,2 @@
1
- import { _ as TraceSpanKind, a as RunTrace, c as TraceContentKind, d as TraceExportQueueOptions, f as TraceExporter, g as TraceSpan, h as TraceRunKind, i as ObservabilityStats, l as TraceContentPolicy, m as TraceRedactorInput, n as CostCalculatorInput, o as TraceAnnotation, p as TraceRedactor, r as ObservabilityOptions, s as TraceContent, t as CostCalculator, u as TraceCost, v as TraceStatus } from "../index-BEqYWean.mjs";
1
+ import { _ as TraceSpanKind, a as RunTrace, c as TraceContentKind, d as TraceExportQueueOptions, f as TraceExporter, g as TraceSpan, h as TraceRunKind, i as ObservabilityStats, l as TraceContentPolicy, m as TraceRedactorInput, n as CostCalculatorInput, o as TraceAnnotation, p as TraceRedactor, r as ObservabilityOptions, s as TraceContent, t as CostCalculator, u as TraceCost, v as TraceStatus } from "../index-B7fxPgn_.mjs";
2
2
  export { CostCalculator, CostCalculatorInput, ObservabilityOptions, ObservabilityStats, RunTrace, TraceAnnotation, TraceContent, TraceContentKind, TraceContentPolicy, TraceCost, TraceExportQueueOptions, TraceExporter, TraceRedactor, TraceRedactorInput, TraceRunKind, TraceSpan, TraceSpanKind, TraceStatus };
@@ -1,2 +1,2 @@
1
- import { i as definePolicy, n as PolicyDecision, r as PolicyDefinition, t as PolicyAuthorization } from "../index-CFzrvDQ0.mjs";
2
- export { PolicyAuthorization, PolicyDecision, PolicyDefinition, definePolicy };
1
+ import { a as definePolicy, i as RiskGuardrailOptions, n as PolicyDecision, o as riskGuardrail, r as PolicyDefinition, t as PolicyAuthorization } from "../index-KKq-_SiK.mjs";
2
+ export { PolicyAuthorization, PolicyDecision, PolicyDefinition, RiskGuardrailOptions, definePolicy, riskGuardrail };
@@ -2,5 +2,43 @@
2
2
  function definePolicy(policy) {
3
3
  return policy;
4
4
  }
5
+ const TOOL_RISKS = [
6
+ "read",
7
+ "write",
8
+ "sensitive",
9
+ "destructive"
10
+ ];
11
+ function riskSet(values, fallback, name) {
12
+ const selected = values ?? fallback;
13
+ for (const risk of selected) if (!TOOL_RISKS.includes(risk)) throw new TypeError(`${name} contains an invalid tool risk: ${risk}`);
14
+ return new Set(selected);
15
+ }
16
+ /**
17
+ * Denies destructive tools and requires approval for sensitive tools by
18
+ * default. Pass explicit lists to change the thresholds.
19
+ */
20
+ function riskGuardrail(options = {}) {
21
+ if (options.name !== void 0 && !options.name.trim()) throw new TypeError("Risk guardrail name must be non-empty");
22
+ const undeclaredRisk = options.undeclaredRisk ?? "allow";
23
+ if (![
24
+ "allow",
25
+ "require_approval",
26
+ "deny"
27
+ ].includes(undeclaredRisk)) throw new TypeError("Risk guardrail undeclaredRisk must be allow, require_approval or deny");
28
+ const deny = riskSet(options.deny, ["destructive"], "deny");
29
+ const requireApproval = riskSet(options.requireApproval, ["sensitive"], "requireApproval");
30
+ return definePolicy({
31
+ name: options.name ?? "risk",
32
+ authorize({ risk, declaredRisk }) {
33
+ if (declaredRisk === void 0) {
34
+ if (undeclaredRisk === "deny") return "deny";
35
+ if (undeclaredRisk === "require_approval") return "require_approval";
36
+ }
37
+ if (deny.has(risk)) return "deny";
38
+ if (requireApproval.has(risk)) return "require_approval";
39
+ return "allow";
40
+ }
41
+ });
42
+ }
5
43
  //#endregion
6
- export { definePolicy };
44
+ export { definePolicy, riskGuardrail };
@@ -1,2 +1,2 @@
1
- import { $ as SessionCompaction, A as ElicitationMode, B as ResumeRunResolution, C as ApprovalMode, D as CoordinatorRun, E as CoordinatorCheckpoint, F as ExecutionCreate, G as RunLease, H as RetainableRunStore, I as ListEventsOptions, J as RunRequest, K as RunPause, L as PendingToolExecution, M as ElicitationResolution, N as EventResolution, O as CredentialStore, P as ExecutionCommit, Q as Session, R as PurgeRunsOptions, S as AgentRunPause, T as ApprovalResolution, U as RunCheckpoint, V as RetainableRunStatus, W as RunCorrelation, X as RunStatus, Y as RunResult, Z as RunStore, _ as createDigestContextCompactor, _t as validatePurgeRunsOptions, at as ToolExecutionRecord, b as resolveContextBudget, c as InMemoryRunStore, ct as WorkflowBudgetUsage, d as ContextCompactionStats, dt as WorkflowRun, et as SessionId, f as ContextCompactor, ft as WorkflowStepRecord, g as ResolvedContextBudget, gt as validateListEventsOptions, h as ModelContextCompactorOptions, ht as isRetainableRunStore, it as TimerResolution, j as ElicitationRequest, k as DurableRunStore, l as ContextCompactionInput, lt as WorkflowCheckpoint, m as DigestContextCompactorOptions, mt as isDurableRunStore, nt as TeamCheckpoint, ot as ToolExecutionResolution, p as ContextTokenEstimator, pt as WorkflowWaitRecord, q as RunRecord, rt as TeamRun, st as ToolExecutionStatus, tt as StoredRunCheckpoint, u as ContextCompactionOptions, ut as WorkflowCompensationRecord, v as createModelContextCompactor, w as ApprovalRequest, x as AgentRun, y as estimateContextTokens, z as PurgeRunsResult } from "../index-lCCFokc6.mjs";
1
+ import { $ as SessionCompaction, A as ElicitationMode, B as ResumeRunResolution, C as ApprovalMode, D as CoordinatorRun, E as CoordinatorCheckpoint, F as ExecutionCreate, G as RunLease, H as RetainableRunStore, I as ListEventsOptions, J as RunRequest, K as RunPause, L as PendingToolExecution, M as ElicitationResolution, N as EventResolution, O as CredentialStore, P as ExecutionCommit, Q as Session, R as PurgeRunsOptions, S as AgentRunPause, T as ApprovalResolution, U as RunCheckpoint, V as RetainableRunStatus, W as RunCorrelation, X as RunStatus, Y as RunResult, Z as RunStore, _ as createDigestContextCompactor, _t as validatePurgeRunsOptions, at as ToolExecutionRecord, b as resolveContextBudget, c as InMemoryRunStore, ct as WorkflowBudgetUsage, d as ContextCompactionStats, dt as WorkflowRun, et as SessionId, f as ContextCompactor, ft as WorkflowStepRecord, g as ResolvedContextBudget, gt as validateListEventsOptions, h as ModelContextCompactorOptions, ht as isRetainableRunStore, it as TimerResolution, j as ElicitationRequest, k as DurableRunStore, l as ContextCompactionInput, lt as WorkflowCheckpoint, m as DigestContextCompactorOptions, mt as isDurableRunStore, nt as TeamCheckpoint, ot as ToolExecutionResolution, p as ContextTokenEstimator, pt as WorkflowWaitRecord, q as RunRecord, rt as TeamRun, st as ToolExecutionStatus, tt as StoredRunCheckpoint, u as ContextCompactionOptions, ut as WorkflowCompensationRecord, v as createModelContextCompactor, w as ApprovalRequest, x as AgentRun, y as estimateContextTokens, z as PurgeRunsResult } from "../index-giFR5t0x.mjs";
2
2
  export { AgentRun, AgentRunPause, ApprovalMode, ApprovalRequest, ApprovalResolution, ContextCompactionInput, ContextCompactionOptions, ContextCompactionStats, ContextCompactor, ContextTokenEstimator, CoordinatorCheckpoint, CoordinatorRun, CredentialStore, DigestContextCompactorOptions, DurableRunStore, ElicitationMode, ElicitationRequest, ElicitationResolution, EventResolution, ExecutionCommit, ExecutionCreate, InMemoryRunStore, ListEventsOptions, ModelContextCompactorOptions, PendingToolExecution, PurgeRunsOptions, PurgeRunsResult, ResolvedContextBudget, ResumeRunResolution, RetainableRunStatus, RetainableRunStore, RunCheckpoint, RunCorrelation, RunLease, RunPause, RunRecord, RunRequest, RunResult, RunStatus, RunStore, Session, SessionCompaction, SessionId, StoredRunCheckpoint, TeamCheckpoint, TeamRun, TimerResolution, ToolExecutionRecord, ToolExecutionResolution, ToolExecutionStatus, WorkflowBudgetUsage, WorkflowCheckpoint, WorkflowCompensationRecord, WorkflowRun, WorkflowStepRecord, WorkflowWaitRecord, createDigestContextCompactor, createModelContextCompactor, estimateContextTokens, isDurableRunStore, isRetainableRunStore, resolveContextBudget, validateListEventsOptions, validatePurgeRunsOptions };
@@ -1,2 +1,2 @@
1
- import { a as SandboxError, c as sandboxResultToJson, i as SandboxCapabilities, n as createLocalSandbox, o as SandboxRunRequest, r as Sandbox, s as SandboxRunResult, t as LocalSandboxOptions } from "../index-DUhNa7IR.mjs";
1
+ import { a as SandboxError, c as sandboxResultToJson, i as SandboxCapabilities, n as createLocalSandbox, o as SandboxRunRequest, r as Sandbox, s as SandboxRunResult, t as LocalSandboxOptions } from "../index-k-gBmfJP.mjs";
2
2
  export { LocalSandboxOptions, Sandbox, SandboxCapabilities, SandboxError, SandboxRunRequest, SandboxRunResult, createLocalSandbox, sandboxResultToJson };
@@ -1,2 +1,2 @@
1
- import { a as TeamMember, c as defineTeam, i as TeamLimits, n as TeamDelegation, o as TeamStep, r as TeamHandoff, s as TeamTaskResult, t as TeamDefinition } from "../index-26ilbzAs.mjs";
1
+ import { a as TeamMember, c as defineTeam, i as TeamLimits, n as TeamDelegation, o as TeamStep, r as TeamHandoff, s as TeamTaskResult, t as TeamDefinition } from "../index-DMmrhb8l.mjs";
2
2
  export { type TeamDefinition, type TeamDelegation, type TeamHandoff, type TeamLimits, type TeamMember, type TeamStep, type TeamTaskResult, defineTeam };
@@ -1,9 +1,9 @@
1
- import { E as ToolProvider } from "../index-DHcfIfh-.mjs";
2
- import { a as ModelResult, n as ModelInput, t as ModelGateway } from "../index-D7r0puBi.mjs";
3
- import { m as ToolCall } from "../types-CckDlhYo.mjs";
4
- import { j as ElicitationRequest, k as DurableRunStore } from "../index-lCCFokc6.mjs";
5
- import { f as MemoryStore } from "../index-CIHWc5V1.mjs";
6
- import { d as ChannelMessage, f as ChannelOutput, o as ChannelElicitationContext, r as ChannelAdapter } from "../index-B8EcvWeN.mjs";
1
+ import { E as ToolProvider } from "../index-AOouohIx.mjs";
2
+ import { a as ModelResult, n as ModelInput, t as ModelGateway } from "../index-Cbe1ZiyN.mjs";
3
+ import { m as ToolCall } from "../types-B6hD1o2I.mjs";
4
+ import { j as ElicitationRequest, k as DurableRunStore } from "../index-giFR5t0x.mjs";
5
+ import { f as MemoryStore } from "../index-D1LAhzgC.mjs";
6
+ import { d as ChannelMessage, f as ChannelOutput, o as ChannelElicitationContext, r as ChannelAdapter } from "../index-AVlWktA8.mjs";
7
7
  //#region src/testing/contracts.d.ts
8
8
  interface ModelGatewayContract {
9
9
  output?: unknown;
@@ -1,3 +1,3 @@
1
- import { A as ToolApproval, C as ConnectionToolPolicy, D as ToolProviderContext, E as ToolProvider, F as ToolRetryPolicy, I as ToolRisk, L as defineTool, M as ToolExecutionContext, N as ToolIdempotency, O as ToolProviderTool, P as ToolResult, R as toToolSpec, S as ConnectionDefinition, T as IntegrationErrorCategory, _ as FevexJsonSchemaProfileLimits, a as InMemoryToolEmbeddingCacheOptions, b as compileFevexJsonSchema, c as ToolEmbeddingIndexEntry, d as cosineSimilarity, f as schemaKeywords, g as FEVEX_JSON_SCHEMA_PROFILE_VERSION, h as toolEmbeddingText, i as InMemoryToolEmbeddingCache, j as ToolDefinition, k as defineConnection, l as ToolEmbeddingMatch, m as toolEmbeddingKey, n as ToolSearchCandidate, o as ToolEmbeddingCache, p as searchToolEmbeddingIndex, r as BuildToolEmbeddingIndexOptions, s as ToolEmbeddingIndex, t as ToolReranker, u as buildToolEmbeddingIndex, v as FevexJsonSchemaProfileOptions, w as IntegrationError, x as validateFevexJsonSchemaProfile, y as FevexJsonSchemaValidator } from "../index-DHcfIfh-.mjs";
2
- import { g as ToolSpec, m as ToolCall } from "../types-CckDlhYo.mjs";
1
+ import { A as ToolApproval, C as ConnectionToolPolicy, D as ToolProviderContext, E as ToolProvider, F as ToolRetryPolicy, I as ToolRisk, L as defineTool, M as ToolExecutionContext, N as ToolIdempotency, O as ToolProviderTool, P as ToolResult, R as toToolSpec, S as ConnectionDefinition, T as IntegrationErrorCategory, _ as FevexJsonSchemaProfileLimits, a as InMemoryToolEmbeddingCacheOptions, b as compileFevexJsonSchema, c as ToolEmbeddingIndexEntry, d as cosineSimilarity, f as schemaKeywords, g as FEVEX_JSON_SCHEMA_PROFILE_VERSION, h as toolEmbeddingText, i as InMemoryToolEmbeddingCache, j as ToolDefinition, k as defineConnection, l as ToolEmbeddingMatch, m as toolEmbeddingKey, n as ToolSearchCandidate, o as ToolEmbeddingCache, p as searchToolEmbeddingIndex, r as BuildToolEmbeddingIndexOptions, s as ToolEmbeddingIndex, t as ToolReranker, u as buildToolEmbeddingIndex, v as FevexJsonSchemaProfileOptions, w as IntegrationError, x as validateFevexJsonSchemaProfile, y as FevexJsonSchemaValidator } from "../index-AOouohIx.mjs";
2
+ import { g as ToolSpec, m as ToolCall } from "../types-B6hD1o2I.mjs";
3
3
  export { BuildToolEmbeddingIndexOptions, ConnectionDefinition, ConnectionToolPolicy, FEVEX_JSON_SCHEMA_PROFILE_VERSION, FevexJsonSchemaProfileLimits, FevexJsonSchemaProfileOptions, FevexJsonSchemaValidator, InMemoryToolEmbeddingCache, InMemoryToolEmbeddingCacheOptions, IntegrationError, IntegrationErrorCategory, ToolApproval, type ToolCall, ToolDefinition, ToolEmbeddingCache, ToolEmbeddingIndex, ToolEmbeddingIndexEntry, ToolEmbeddingMatch, ToolExecutionContext, ToolIdempotency, ToolProvider, ToolProviderContext, ToolProviderTool, ToolReranker, ToolResult, ToolRetryPolicy, ToolRisk, ToolSearchCandidate, type ToolSpec, buildToolEmbeddingIndex, compileFevexJsonSchema, cosineSimilarity, defineConnection, defineTool, schemaKeywords, searchToolEmbeddingIndex, toToolSpec, toolEmbeddingKey, toolEmbeddingText, validateFevexJsonSchemaProfile };
@@ -258,7 +258,7 @@ interface ToolEventSource {
258
258
  connectionName: string;
259
259
  remoteToolName: string;
260
260
  }
261
- type AgentEventType = 'run.started' | 'run.recovered' | 'run.paused' | 'run.resumed' | 'model.started' | 'model.output.delta' | 'model.completed' | 'context.compacted' | 'tool.started' | 'tool.completed' | 'tool.failed' | 'tool.retrying' | 'tool.execution_unknown' | 'artifact.created' | 'elicitation.requested' | 'elicitation.resolved' | 'approval.requested' | 'approval.resolved' | 'run.completed' | 'run.failed' | 'run.cancelled' | 'workflow.run.started' | 'workflow.run.recovered' | 'workflow.step.started' | 'workflow.step.completed' | 'workflow.step.failed' | 'workflow.compensation.started' | 'workflow.compensation.completed' | 'workflow.compensation.failed' | 'workflow.wait.started' | 'workflow.wait.completed' | 'workflow.run.paused' | 'workflow.run.resumed' | 'workflow.run.completed' | 'workflow.run.failed' | 'workflow.run.cancelled' | 'team.run.started' | 'team.run.recovered' | 'team.agent.assigned' | 'team.handoff.created' | 'team.task.completed' | 'team.task.failed' | 'team.merge.started' | 'team.merge.completed' | 'team.merge.failed' | 'team.run.paused' | 'team.run.resumed' | 'team.run.completed' | 'team.run.failed' | 'team.run.cancelled';
261
+ type AgentEventType = 'run.started' | 'run.recovered' | 'run.paused' | 'run.resumed' | 'model.started' | 'model.output.delta' | 'model.completed' | 'context.compacted' | 'memory.completed' | 'tool.started' | 'tool.completed' | 'tool.failed' | 'tool.retrying' | 'tool.execution_unknown' | 'artifact.created' | 'elicitation.requested' | 'elicitation.resolved' | 'approval.requested' | 'approval.resolved' | 'policy.evaluated' | 'run.completed' | 'run.failed' | 'run.cancelled' | 'workflow.run.started' | 'workflow.run.recovered' | 'workflow.step.started' | 'workflow.step.completed' | 'workflow.step.failed' | 'workflow.compensation.started' | 'workflow.compensation.completed' | 'workflow.compensation.failed' | 'workflow.wait.started' | 'workflow.wait.completed' | 'workflow.run.paused' | 'workflow.run.resumed' | 'workflow.run.completed' | 'workflow.run.failed' | 'workflow.run.cancelled' | 'team.run.started' | 'team.run.recovered' | 'team.agent.assigned' | 'team.handoff.created' | 'team.task.completed' | 'team.task.failed' | 'team.merge.started' | 'team.merge.completed' | 'team.merge.failed' | 'team.run.paused' | 'team.run.resumed' | 'team.run.completed' | 'team.run.failed' | 'team.run.cancelled';
262
262
  interface AgentEventPayloads {
263
263
  'run.started': undefined;
264
264
  'run.recovered': {
@@ -306,10 +306,19 @@ interface AgentEventPayloads {
306
306
  teamDelegationId?: string;
307
307
  teamAgentName?: string;
308
308
  };
309
+ 'memory.completed': {
310
+ operation: 'search' | 'write';
311
+ durationMs: number;
312
+ recordCount?: number;
313
+ recordId?: string;
314
+ error?: string;
315
+ };
309
316
  'tool.started': {
310
317
  step: number;
311
318
  toolCallId: string;
312
319
  toolName: string;
320
+ risk?: 'read' | 'write' | 'sensitive' | 'destructive';
321
+ declaredRisk?: 'read' | 'write' | 'sensitive' | 'destructive';
313
322
  attempt?: number;
314
323
  source?: ToolEventSource;
315
324
  workflowStepId?: string;
@@ -422,6 +431,15 @@ interface AgentEventPayloads {
422
431
  teamDelegationId?: string;
423
432
  teamAgentName?: string;
424
433
  };
434
+ 'policy.evaluated': {
435
+ policyName: string;
436
+ toolName: string;
437
+ toolCallId?: string;
438
+ action: 'tool.execute' | 'approval.resolve';
439
+ decision: 'allow' | 'deny' | 'require_approval';
440
+ risk: 'read' | 'write' | 'sensitive' | 'destructive';
441
+ declaredRisk?: 'read' | 'write' | 'sensitive' | 'destructive';
442
+ };
425
443
  'run.completed': {
426
444
  output: JsonValue;
427
445
  usage?: JsonObject;
@@ -1,2 +1,2 @@
1
- import { a as WorkflowStep, c as defineWorkflow, i as WorkflowEventResult, n as WorkflowDefinition, o as WorkflowStepContext, r as WorkflowEventDefinition, s as WorkflowStepOptions, t as WorkflowAgentResult } from "../index-Btth7rdL.mjs";
1
+ import { a as WorkflowStep, c as defineWorkflow, i as WorkflowEventResult, n as WorkflowDefinition, o as WorkflowStepContext, r as WorkflowEventDefinition, s as WorkflowStepOptions, t as WorkflowAgentResult } from "../index-CAVMQT9j.mjs";
2
2
  export { WorkflowAgentResult, WorkflowDefinition, WorkflowEventDefinition, WorkflowEventResult, WorkflowStep, WorkflowStepContext, WorkflowStepOptions, defineWorkflow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fevex/core",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "Agent Engineering Framework for code-first, provider-neutral AI agents.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",