@fevex/core 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (41) hide show
  1. package/README.md +183 -2
  2. package/dist/agents/index.d.mts +1 -1
  3. package/dist/artifacts/index.d.mts +2 -0
  4. package/dist/artifacts/index.mjs +2 -0
  5. package/dist/artifacts-gUzemET7.mjs +440 -0
  6. package/dist/channels/index.d.mts +2 -2
  7. package/dist/channels/index.mjs +70 -28
  8. package/dist/evals/index.d.mts +4 -4
  9. package/dist/{fevex-Ddyi6z6L.d.mts → fevex-B5NxFKcV.d.mts} +41 -11
  10. package/dist/http/index.d.mts +65 -5
  11. package/dist/http/index.mjs +236 -16
  12. package/dist/{index-Bgcxgy66.d.mts → index--_LdSEuF.d.mts} +31 -10
  13. package/dist/{index-CrOId2px.d.mts → index-BFnWUu7j.d.mts} +1 -1
  14. package/dist/{index-CTIwrVf9.d.mts → index-BPwkgdo3.d.mts} +1 -1
  15. package/dist/{index-DviHtsLo.d.mts → index-Br-zPxZH.d.mts} +2 -2
  16. package/dist/{index-Dx_LotWZ.d.mts → index-CGmHXV31.d.mts} +38 -3
  17. package/dist/{index-CqOjvtQ9.d.mts → index-CKQCNvJz.d.mts} +4 -2
  18. package/dist/{index-dkFyTNh4.d.mts → index-Cb3AB98n.d.mts} +2 -2
  19. package/dist/{index-B4PIkqOU.d.mts → index-D6lnI92z.d.mts} +3 -3
  20. package/dist/{index-Bg9rr8Qe.d.mts → index-Dsulk-n6.d.mts} +3 -3
  21. package/dist/{index-DeXUtyd9.d.mts → index-aayvtf0J.d.mts} +2 -2
  22. package/dist/index.d.mts +13 -13
  23. package/dist/index.mjs +464 -103
  24. package/dist/knowledge/index.d.mts +1 -1
  25. package/dist/model-stream-JQdHDDcj.mjs +131 -0
  26. package/dist/models/index.d.mts +1 -1
  27. package/dist/observability/index.d.mts +1 -1
  28. package/dist/policies/index.d.mts +1 -1
  29. package/dist/{model-stream-u2xMsEaf.mjs → run-support-CmZ6Xo6H.mjs} +41 -130
  30. package/dist/runtime/index.d.mts +2 -2
  31. package/dist/runtime/index.mjs +43 -1
  32. package/dist/sandbox/index.d.mts +1 -1
  33. package/dist/sandbox/index.mjs +42 -17
  34. package/dist/teams/index.d.mts +1 -1
  35. package/dist/testing/index.d.mts +13 -7
  36. package/dist/testing/index.mjs +98 -2
  37. package/dist/tools/index.d.mts +2 -2
  38. package/dist/types-BDVUoAU6.d.mts +559 -0
  39. package/dist/workflows/index.d.mts +1 -1
  40. package/package.json +6 -2
  41. package/dist/types-CuoRx12Q.d.mts +0 -333
@@ -1,5 +1,6 @@
1
+ import { isRetainableRunStore } from "../runtime/index.mjs";
1
2
  import { IntegrationError } from "../tools/index.mjs";
2
- import { t as readModelStream } from "../model-stream-u2xMsEaf.mjs";
3
+ import { t as readModelStream } from "../model-stream-JQdHDDcj.mjs";
3
4
  //#region src/testing/contracts.ts
4
5
  const contractOutputSchema = {
5
6
  type: "object",
@@ -126,6 +127,10 @@ async function testChannelAdapter(adapter, contract) {
126
127
  if (contract.output.threadId !== void 0) assert(contract.output.threadId.trim(), "ChannelOutput threadId cannot be empty");
127
128
  if (contract.output.metadata !== void 0) JSON.stringify(contract.output.metadata);
128
129
  assert(JSON.stringify(await adapter.deliver(contract.output, {})) === JSON.stringify(contract.delivered), "ChannelAdapter returned an unexpected delivery");
130
+ if (contract.elicitation) {
131
+ assert(adapter.deliverElicitation, "ChannelAdapter must support elicitation delivery");
132
+ for (let attempt = 0; attempt < 2; attempt += 1) assert(JSON.stringify(await adapter.deliverElicitation(structuredClone(contract.elicitation.request), { ...contract.elicitation.context })) === JSON.stringify(contract.elicitation.delivered), "ChannelAdapter returned an unexpected elicitation delivery or retry receipt");
133
+ }
129
134
  }
130
135
  async function testModelGateway(model, contract = {}) {
131
136
  const output = contract.output ?? { answer: "ok" };
@@ -595,6 +600,97 @@ async function testRunStore(store) {
595
600
  }), "The current generation must be able to commit");
596
601
  await store.releaseLease(runId, takeoverLease.ownerId, takeoverLease.generation);
597
602
  }
603
+ async function testRetentionStore(store) {
604
+ assert(isRetainableRunStore(store), "RunStore must implement purgeRuns");
605
+ const suffix = crypto.randomUUID();
606
+ const now = Date.now();
607
+ const old = (/* @__PURE__ */ new Date(now - 2 * 864e5)).toISOString();
608
+ const before = (/* @__PURE__ */ new Date(now - 864e5)).toISOString();
609
+ const recent = new Date(now).toISOString();
610
+ const entries = [
611
+ {
612
+ id: `retention-old-completed-${suffix}`,
613
+ status: "completed",
614
+ createdAt: old
615
+ },
616
+ {
617
+ id: `retention-old-failed-${suffix}`,
618
+ status: "failed",
619
+ createdAt: old
620
+ },
621
+ {
622
+ id: `retention-recent-completed-${suffix}`,
623
+ status: "completed",
624
+ createdAt: recent
625
+ },
626
+ {
627
+ id: `retention-old-running-${suffix}`,
628
+ status: "running",
629
+ createdAt: old
630
+ }
631
+ ];
632
+ for (const entry of entries) {
633
+ const sessionId = `retention-session-${entry.id}`;
634
+ await store.saveSession({
635
+ id: sessionId,
636
+ history: [],
637
+ createdAt: entry.createdAt,
638
+ updatedAt: entry.createdAt
639
+ });
640
+ await store.saveRun({
641
+ id: entry.id,
642
+ sessionId,
643
+ agentName: "retention-agent",
644
+ status: entry.status,
645
+ revision: 1,
646
+ createdAt: entry.createdAt,
647
+ updatedAt: entry.createdAt
648
+ });
649
+ await store.appendEvent({
650
+ id: `retention-event-${entry.id}`,
651
+ sequence: 1,
652
+ type: "run.started",
653
+ runId: entry.id,
654
+ timestamp: entry.createdAt
655
+ });
656
+ }
657
+ const purged = await store.purgeRuns({ before });
658
+ assert(purged.runs === 2, "Retention must delete only old terminal runs");
659
+ assert(purged.sessions === 2, "Retention must delete sessions left without runs");
660
+ assert(!await store.getRun(entries[0].id), "Retention must delete the completed run");
661
+ assert(!await store.getRun(entries[1].id), "Retention must delete the failed run");
662
+ assert(await store.getRun(entries[2].id), "Retention must keep recent terminal runs");
663
+ assert(await store.getRun(entries[3].id), "Retention must keep active runs");
664
+ assert(!await store.getSession(`retention-session-${entries[0].id}`), "Retention must delete empty sessions");
665
+ assert(await store.getSession(`retention-session-${entries[2].id}`), "Retention must keep sessions with runs");
666
+ assert((await store.purgeRuns({ limit: 1 })).runs === 1, "Retention must honor the limit");
667
+ await store.purgeRuns({ before: new Date(Date.now() + 864e5).toISOString() });
668
+ assert(!await store.getRun(entries[2].id), "Retention must purge remaining terminal runs");
669
+ assert(await store.getRun(entries[3].id), "Retention must keep active runs after a full purge");
670
+ const boundaryId = `retention-boundary-${suffix}`;
671
+ const boundarySessionId = `retention-boundary-session-${suffix}`;
672
+ const boundaryCreatedAt = "2020-01-01T00:00:00.100Z";
673
+ await store.saveSession({
674
+ id: boundarySessionId,
675
+ history: [],
676
+ createdAt: boundaryCreatedAt,
677
+ updatedAt: boundaryCreatedAt
678
+ });
679
+ await store.saveRun({
680
+ id: boundaryId,
681
+ sessionId: boundarySessionId,
682
+ agentName: "retention-agent",
683
+ status: "completed",
684
+ revision: 1,
685
+ createdAt: boundaryCreatedAt,
686
+ updatedAt: boundaryCreatedAt
687
+ });
688
+ assert((await store.purgeRuns({
689
+ before: "2020-01-01T00:00:00.500Z",
690
+ statuses: ["completed"]
691
+ })).runs === 1, "Retention must compare subsecond timestamps");
692
+ assert(!await store.getRun(boundaryId), "Retention must delete the boundary run");
693
+ }
598
694
  //#endregion
599
695
  //#region src/testing/fake-model.ts
600
696
  /** Creates a deterministic model gateway for unit tests. */
@@ -622,4 +718,4 @@ function fakeModel(...responses) {
622
718
  };
623
719
  }
624
720
  //#endregion
625
- export { fakeModel, testChannelAdapter, testMemoryStore, testModelGateway, testRunStore, testToolProvider };
721
+ export { fakeModel, testChannelAdapter, testMemoryStore, testModelGateway, testRetentionStore, testRunStore, testToolProvider };
@@ -1,3 +1,3 @@
1
- import { g as ToolSpec, m as ToolCall } from "../types-CuoRx12Q.mjs";
2
- import { C as toToolSpec, S as defineTool, _ as ToolExecutionContext, a as compileFevexJsonSchema, b as ToolRetryPolicy, c as ConnectionToolPolicy, d as ToolProvider, f as ToolProviderContext, g as ToolDefinition, h as ToolApproval, i as FevexJsonSchemaValidator, l as IntegrationError, m as defineConnection, n as FevexJsonSchemaProfileLimits, o as validateFevexJsonSchemaProfile, p as ToolProviderTool, r as FevexJsonSchemaProfileOptions, s as ConnectionDefinition, t as FEVEX_JSON_SCHEMA_PROFILE_VERSION, u as IntegrationErrorCategory, v as ToolIdempotency, x as ToolRisk, y as ToolResult } from "../index-CqOjvtQ9.mjs";
1
+ import { g as ToolSpec, m as ToolCall } from "../types-BDVUoAU6.mjs";
2
+ import { C as toToolSpec, S as defineTool, _ as ToolExecutionContext, a as compileFevexJsonSchema, b as ToolRetryPolicy, c as ConnectionToolPolicy, d as ToolProvider, f as ToolProviderContext, g as ToolDefinition, h as ToolApproval, i as FevexJsonSchemaValidator, l as IntegrationError, m as defineConnection, n as FevexJsonSchemaProfileLimits, o as validateFevexJsonSchemaProfile, p as ToolProviderTool, r as FevexJsonSchemaProfileOptions, s as ConnectionDefinition, t as FEVEX_JSON_SCHEMA_PROFILE_VERSION, u as IntegrationErrorCategory, v as ToolIdempotency, x as ToolRisk, y as ToolResult } from "../index-CKQCNvJz.mjs";
3
3
  export { ConnectionDefinition, ConnectionToolPolicy, FEVEX_JSON_SCHEMA_PROFILE_VERSION, FevexJsonSchemaProfileLimits, FevexJsonSchemaProfileOptions, FevexJsonSchemaValidator, IntegrationError, IntegrationErrorCategory, ToolApproval, type ToolCall, ToolDefinition, ToolExecutionContext, ToolIdempotency, ToolProvider, ToolProviderContext, ToolProviderTool, ToolResult, ToolRetryPolicy, ToolRisk, type ToolSpec, compileFevexJsonSchema, defineConnection, defineTool, toToolSpec, validateFevexJsonSchemaProfile };
@@ -0,0 +1,559 @@
1
+ //#region src/artifacts/artifacts.d.ts
2
+ /** Stable identifier for a stored artifact. */
3
+ type ArtifactId = string;
4
+ /**
5
+ * Small, JSON-serializable reference to a stored artifact.
6
+ *
7
+ * The bytes live in an `ArtifactStore`; runs, events and prompts only carry
8
+ * this descriptor.
9
+ */
10
+ interface ArtifactDescriptor {
11
+ artifactId: ArtifactId;
12
+ /** Stable URI for host and protocol hand-offs, for example `artifact://<id>`. */
13
+ uri: string;
14
+ filename: string;
15
+ mimeType: string;
16
+ size: number;
17
+ sha256: string;
18
+ createdAt: string;
19
+ expiresAt?: string;
20
+ metadata?: JsonObject;
21
+ }
22
+ interface ArtifactWrite {
23
+ filename: string;
24
+ mimeType: string;
25
+ bytes: Uint8Array;
26
+ metadata?: JsonObject;
27
+ expiresAt?: string;
28
+ }
29
+ interface ArtifactContent {
30
+ descriptor: ArtifactDescriptor;
31
+ bytes: Uint8Array;
32
+ }
33
+ /** Scope supplied by the host when reading or writing an artifact. */
34
+ interface ArtifactStoreContext {
35
+ tenantId?: string;
36
+ runId?: string;
37
+ sessionId?: string;
38
+ actor?: ExecutionContext['actor'];
39
+ signal?: AbortSignal;
40
+ }
41
+ /**
42
+ * Durable storage for large or binary outputs.
43
+ *
44
+ * Implementations must never return mutable internal state; callers may mutate
45
+ * the returned descriptor or bytes.
46
+ */
47
+ interface ArtifactStore {
48
+ put(input: ArtifactWrite, context?: ArtifactStoreContext): Promise<ArtifactDescriptor>;
49
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactContent | null>;
50
+ head?(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactDescriptor | null>;
51
+ delete?(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
52
+ }
53
+ type ArtifactErrorCode = 'ARTIFACT_INVALID_INPUT' | 'ARTIFACT_TOO_LARGE' | 'ARTIFACT_MIME_UNSUPPORTED' | 'ARTIFACT_INVALID_ID' | 'ARTIFACT_INVALID_CONTEXT' | 'ARTIFACT_CONFLICT' | 'ARTIFACT_CORRUPT';
54
+ declare class ArtifactError extends Error {
55
+ readonly code: ArtifactErrorCode;
56
+ constructor(code: ArtifactErrorCode, message: string);
57
+ }
58
+ /** Metadata record indexed by an `ArtifactCatalog`. */
59
+ interface ArtifactRecord {
60
+ descriptor: ArtifactDescriptor;
61
+ tenantId: string;
62
+ runId?: string;
63
+ sessionId?: string;
64
+ actorId?: string;
65
+ }
66
+ interface ArtifactQuery {
67
+ runId?: string;
68
+ sessionId?: string;
69
+ actorId?: string;
70
+ mimeType?: string;
71
+ /** Include expired artifacts. Defaults to false. */
72
+ includeExpired?: boolean;
73
+ /** Maximum records to return. Defaults to 100 and is capped at 1000. */
74
+ limit?: number;
75
+ }
76
+ /**
77
+ * Queryable metadata index for artifacts.
78
+ *
79
+ * The bytes stay in an `ArtifactStore`; the catalog lets hosts list, authorize
80
+ * and delete by tenant, run, session or actor without scanning object storage.
81
+ */
82
+ interface ArtifactCatalog {
83
+ save(record: ArtifactRecord, context?: ArtifactStoreContext): Promise<void>;
84
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactRecord | null>;
85
+ list(query?: ArtifactQuery, context?: ArtifactStoreContext): Promise<ArtifactRecord[]>;
86
+ delete(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
87
+ deleteByRun(runId: string, context?: ArtifactStoreContext): Promise<number>;
88
+ }
89
+ /** Resolves and validates the tenant scope used by stores and catalogs. */
90
+ declare function artifactTenantId(context?: ArtifactStoreContext): string;
91
+ /** Validates an artifact id before using it in a query or storage key. */
92
+ declare function assertArtifactId(artifactId: string): void;
93
+ //#endregion
94
+ //#region src/artifacts/cataloged-artifact-store.d.ts
95
+ interface CatalogedArtifactStoreOptions {
96
+ /** Byte store, for example `FileSystemArtifactStore` or `S3ArtifactStore`. */
97
+ store: ArtifactStore;
98
+ /** Metadata index, for example `SQLiteArtifactCatalog` or `PostgresArtifactCatalog`. */
99
+ catalog: ArtifactCatalog;
100
+ }
101
+ /**
102
+ * Composes a byte store with a queryable metadata catalog.
103
+ *
104
+ * `put` writes bytes first and then indexes metadata. If indexing fails, the
105
+ * bytes are deleted so the catalog never points at a half-written artifact.
106
+ */
107
+ declare class CatalogedArtifactStore implements ArtifactStore {
108
+ #private;
109
+ constructor(options: CatalogedArtifactStoreOptions);
110
+ put(input: ArtifactWrite, context?: ArtifactStoreContext): Promise<ArtifactDescriptor>;
111
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactContent | null>;
112
+ head(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactDescriptor | null>;
113
+ delete(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
114
+ list(query?: ArtifactQuery, context?: ArtifactStoreContext): Promise<ArtifactRecord[]>;
115
+ deleteByRun(runId: string, context?: ArtifactStoreContext): Promise<number>;
116
+ }
117
+ //#endregion
118
+ //#region src/artifacts/internal.d.ts
119
+ interface ArtifactStoreLimits {
120
+ maxBytes?: number;
121
+ allowedMimeTypes?: readonly string[];
122
+ retentionMs?: number;
123
+ }
124
+ //#endregion
125
+ //#region src/artifacts/file-system-artifact-store.d.ts
126
+ interface FileSystemArtifactStoreOptions extends ArtifactStoreLimits {
127
+ /** Directory that owns artifact bytes and metadata. */
128
+ rootDir: string;
129
+ }
130
+ /**
131
+ * Local filesystem artifact store.
132
+ *
133
+ * Layout:
134
+ * <rootDir>/tenants/<tenantId>/artifacts/<artifactId>
135
+ * <rootDir>/tenants/<tenantId>/artifacts/<artifactId>.json
136
+ *
137
+ * Bytes are written before metadata, and both use an atomic rename. This is
138
+ * intended for local development and single-node deployments; use
139
+ * `S3ArtifactStore` for multi-instance production.
140
+ */
141
+ declare class FileSystemArtifactStore implements ArtifactStore {
142
+ #private;
143
+ constructor(options: FileSystemArtifactStoreOptions);
144
+ put(input: ArtifactWrite, context?: ArtifactStoreContext): Promise<ArtifactDescriptor>;
145
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactContent | null>;
146
+ head(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactDescriptor | null>;
147
+ delete(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
148
+ }
149
+ //#endregion
150
+ //#region src/artifacts/in-memory-artifact-catalog.d.ts
151
+ /** Volatile artifact metadata catalog for tests and local development. */
152
+ declare class InMemoryArtifactCatalog implements ArtifactCatalog {
153
+ #private;
154
+ save(record: ArtifactRecord, context?: ArtifactStoreContext): Promise<void>;
155
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactRecord | null>;
156
+ list(query?: ArtifactQuery, context?: ArtifactStoreContext): Promise<ArtifactRecord[]>;
157
+ delete(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
158
+ deleteByRun(runId: string, context?: ArtifactStoreContext): Promise<number>;
159
+ }
160
+ //#endregion
161
+ //#region src/artifacts/in-memory-artifact-store.d.ts
162
+ interface InMemoryArtifactStoreOptions extends ArtifactStoreLimits {}
163
+ /** Volatile artifact store for tests and local development. */
164
+ declare class InMemoryArtifactStore implements ArtifactStore {
165
+ #private;
166
+ constructor(options?: InMemoryArtifactStoreOptions);
167
+ put(input: ArtifactWrite, context?: ArtifactStoreContext): Promise<ArtifactDescriptor>;
168
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactContent | null>;
169
+ head(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactDescriptor | null>;
170
+ delete(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
171
+ }
172
+ //#endregion
173
+ //#region src/artifacts/s3-artifact-store.d.ts
174
+ /**
175
+ * Minimal S3-compatible object client.
176
+ *
177
+ * Wrap `@aws-sdk/client-s3`, a Cloudflare R2 client, MinIO or any other
178
+ * S3-compatible SDK with this interface. Fevex does not depend on an object
179
+ * storage SDK.
180
+ */
181
+ interface S3ObjectClient {
182
+ putObject(input: {
183
+ key: string;
184
+ body: Uint8Array;
185
+ contentType: string;
186
+ metadata?: Record<string, string>;
187
+ }): Promise<void>;
188
+ getObject(input: {
189
+ key: string;
190
+ }): Promise<Uint8Array | null>;
191
+ deleteObject(input: {
192
+ key: string;
193
+ }): Promise<void>;
194
+ }
195
+ interface S3ArtifactStoreOptions extends ArtifactStoreLimits {
196
+ client: S3ObjectClient;
197
+ /** Key prefix. Defaults to `fevex`. */
198
+ prefix?: string;
199
+ }
200
+ /**
201
+ * Artifact store for S3-compatible object storage (S3, R2, MinIO, GCS via an
202
+ * S3 gateway, and similar).
203
+ *
204
+ * Bytes are stored at `<prefix>/<tenant>/artifacts/<artifactId>` and metadata
205
+ * in a `.json` sidecar next to them. The bucket should stay private; the host
206
+ * serves downloads through its authenticated API or short-lived signed URLs.
207
+ */
208
+ declare class S3ArtifactStore implements ArtifactStore {
209
+ #private;
210
+ constructor(options: S3ArtifactStoreOptions);
211
+ put(input: ArtifactWrite, context?: ArtifactStoreContext): Promise<ArtifactDescriptor>;
212
+ get(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactContent | null>;
213
+ head(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<ArtifactDescriptor | null>;
214
+ delete(artifactId: ArtifactId, context?: ArtifactStoreContext): Promise<boolean>;
215
+ }
216
+ //#endregion
217
+ //#region src/core/types.d.ts
218
+ /** A value that can cross provider and persistence boundaries without conversion. */
219
+ type JsonPrimitive = string | number | boolean | null;
220
+ type JsonObject = {
221
+ [key: string]: JsonValue;
222
+ };
223
+ type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
224
+ type RunId = string;
225
+ declare const SCHEMA_NOT_TRANSPORTABLE = "SCHEMA_NOT_TRANSPORTABLE";
226
+ declare const PROVIDER_SCHEMA_UNSUPPORTED = "PROVIDER_SCHEMA_UNSUPPORTED";
227
+ declare const PROVIDER_REASONING_UNSUPPORTED = "PROVIDER_REASONING_UNSUPPORTED";
228
+ interface ExecutionContext {
229
+ namespace?: string;
230
+ actor?: {
231
+ id: string;
232
+ type?: string;
233
+ };
234
+ attributes?: JsonObject;
235
+ prompt?: JsonObject;
236
+ }
237
+ type AgentMessageRole = 'system' | 'user' | 'assistant' | 'tool';
238
+ interface AgentMessage {
239
+ role: AgentMessageRole;
240
+ content: string;
241
+ name?: string;
242
+ toolCallId?: string;
243
+ toolCalls?: ToolCall[];
244
+ }
245
+ interface ToolSpec {
246
+ name: string;
247
+ description?: string;
248
+ inputSchema?: JsonObject;
249
+ }
250
+ interface ToolCall {
251
+ id: string;
252
+ name: string;
253
+ input: JsonValue;
254
+ }
255
+ interface ToolEventSource {
256
+ kind: 'connection';
257
+ provider: string;
258
+ connectionName: string;
259
+ remoteToolName: string;
260
+ }
261
+ type AgentEventType = 'run.started' | 'run.recovered' | 'run.paused' | 'run.resumed' | 'model.started' | 'model.output.delta' | 'model.completed' | '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';
262
+ interface AgentEventPayloads {
263
+ 'run.started': undefined;
264
+ 'run.recovered': {
265
+ actorId: string;
266
+ };
267
+ 'run.paused': {
268
+ reason: 'elicitation' | 'approval' | 'tool_execution_unknown';
269
+ toolCallId: string;
270
+ };
271
+ 'run.resumed': undefined;
272
+ 'model.started': {
273
+ step: number;
274
+ workflowStepId?: string;
275
+ workflowAgentName?: string;
276
+ teamDelegationId?: string;
277
+ teamAgentName?: string;
278
+ };
279
+ 'model.output.delta': {
280
+ step: number;
281
+ delta: string;
282
+ workflowStepId?: string;
283
+ workflowAgentName?: string;
284
+ teamDelegationId?: string;
285
+ teamAgentName?: string;
286
+ };
287
+ 'model.completed': {
288
+ step: number;
289
+ usage?: JsonObject;
290
+ workflowStepId?: string;
291
+ workflowAgentName?: string;
292
+ teamDelegationId?: string;
293
+ teamAgentName?: string;
294
+ };
295
+ 'tool.started': {
296
+ step: number;
297
+ toolCallId: string;
298
+ toolName: string;
299
+ attempt?: number;
300
+ source?: ToolEventSource;
301
+ workflowStepId?: string;
302
+ workflowAgentName?: string;
303
+ teamDelegationId?: string;
304
+ teamAgentName?: string;
305
+ };
306
+ 'tool.completed': {
307
+ step: number;
308
+ toolCallId: string;
309
+ toolName: string;
310
+ attempt?: number;
311
+ source?: ToolEventSource;
312
+ workflowStepId?: string;
313
+ workflowAgentName?: string;
314
+ teamDelegationId?: string;
315
+ teamAgentName?: string;
316
+ };
317
+ 'tool.failed': {
318
+ step: number;
319
+ toolCallId: string;
320
+ toolName: string;
321
+ error: string;
322
+ errorCode?: string;
323
+ retryable?: boolean;
324
+ source?: ToolEventSource;
325
+ workflowStepId?: string;
326
+ workflowAgentName?: string;
327
+ teamDelegationId?: string;
328
+ teamAgentName?: string;
329
+ };
330
+ 'tool.retrying': {
331
+ step: number;
332
+ toolCallId: string;
333
+ toolName: string;
334
+ attempt: number;
335
+ delayMs: number;
336
+ error: string;
337
+ errorCode?: string;
338
+ retryable?: boolean;
339
+ source?: ToolEventSource;
340
+ workflowStepId?: string;
341
+ workflowAgentName?: string;
342
+ teamDelegationId?: string;
343
+ teamAgentName?: string;
344
+ };
345
+ 'tool.execution_unknown': {
346
+ step: number;
347
+ toolCallId: string;
348
+ toolName: string;
349
+ source?: ToolEventSource;
350
+ workflowStepId?: string;
351
+ workflowAgentName?: string;
352
+ teamDelegationId?: string;
353
+ teamAgentName?: string;
354
+ };
355
+ 'artifact.created': {
356
+ descriptor: ArtifactDescriptor;
357
+ toolCallId?: string;
358
+ toolName?: string;
359
+ source?: ToolEventSource;
360
+ workflowStepId?: string;
361
+ workflowAgentName?: string;
362
+ teamDelegationId?: string;
363
+ teamAgentName?: string;
364
+ };
365
+ 'elicitation.requested': {
366
+ request: {
367
+ id: string;
368
+ toolCallId: string;
369
+ prompt: string;
370
+ responseSchema: JsonObject;
371
+ requestedAt: string;
372
+ expiresAt?: string;
373
+ };
374
+ workflowStepId?: string;
375
+ workflowAgentName?: string;
376
+ teamDelegationId?: string;
377
+ teamAgentName?: string;
378
+ };
379
+ 'elicitation.resolved': {
380
+ requestId: string;
381
+ toolCallId: string;
382
+ actorId: string;
383
+ workflowStepId?: string;
384
+ workflowAgentName?: string;
385
+ teamDelegationId?: string;
386
+ teamAgentName?: string;
387
+ };
388
+ 'approval.requested': {
389
+ approvalId: string;
390
+ toolCallId: string;
391
+ toolName: string;
392
+ toolLabel?: string;
393
+ source?: ToolEventSource;
394
+ workflowStepId?: string;
395
+ workflowAgentName?: string;
396
+ teamDelegationId?: string;
397
+ teamAgentName?: string;
398
+ };
399
+ 'approval.resolved': {
400
+ approvalId: string;
401
+ toolCallId: string;
402
+ decision: 'approve' | 'reject';
403
+ actorId: string;
404
+ toolLabel?: string;
405
+ source?: ToolEventSource;
406
+ workflowStepId?: string;
407
+ workflowAgentName?: string;
408
+ teamDelegationId?: string;
409
+ teamAgentName?: string;
410
+ };
411
+ 'run.completed': {
412
+ output: JsonValue;
413
+ usage?: JsonObject;
414
+ };
415
+ 'run.failed': {
416
+ error: string;
417
+ errorCode?: string;
418
+ retryable?: boolean;
419
+ source?: ToolEventSource;
420
+ };
421
+ 'run.cancelled': {
422
+ reason: 'aborted' | 'timeout' | 'approval_rejected';
423
+ };
424
+ 'workflow.run.started': undefined;
425
+ 'workflow.run.recovered': {
426
+ actorId: string;
427
+ };
428
+ 'workflow.step.started': {
429
+ stepId: string;
430
+ kind: 'agent' | 'parallel';
431
+ agentName?: string;
432
+ };
433
+ 'workflow.step.completed': {
434
+ stepId: string;
435
+ kind: 'agent' | 'parallel';
436
+ };
437
+ 'workflow.step.failed': {
438
+ stepId: string;
439
+ kind: 'agent' | 'parallel';
440
+ error: string;
441
+ };
442
+ 'workflow.compensation.started': {
443
+ stepId: string;
444
+ kind: 'agent' | 'parallel';
445
+ };
446
+ 'workflow.compensation.completed': {
447
+ stepId: string;
448
+ kind: 'agent' | 'parallel';
449
+ };
450
+ 'workflow.compensation.failed': {
451
+ stepId: string;
452
+ kind: 'agent' | 'parallel';
453
+ error: string;
454
+ };
455
+ 'workflow.wait.started': {
456
+ stepId: string;
457
+ kind: 'timer' | 'event';
458
+ resumeAt?: string;
459
+ eventName?: string;
460
+ };
461
+ 'workflow.wait.completed': {
462
+ stepId: string;
463
+ kind: 'timer' | 'event';
464
+ payload?: JsonValue;
465
+ actorId?: string;
466
+ receivedAt?: string;
467
+ };
468
+ 'workflow.run.paused': {
469
+ stepId: string;
470
+ reason: 'child' | 'timer' | 'event';
471
+ childRunId?: string;
472
+ };
473
+ 'workflow.run.resumed': undefined;
474
+ 'workflow.run.completed': {
475
+ output: JsonValue;
476
+ usage?: JsonObject;
477
+ };
478
+ 'workflow.run.failed': {
479
+ error: string;
480
+ errorCode?: string;
481
+ retryable?: boolean;
482
+ source?: ToolEventSource;
483
+ };
484
+ 'workflow.run.cancelled': {
485
+ reason: 'aborted' | 'timeout' | 'approval_rejected';
486
+ };
487
+ 'team.run.started': undefined;
488
+ 'team.run.recovered': {
489
+ actorId: string;
490
+ };
491
+ 'team.agent.assigned': {
492
+ delegationId: string;
493
+ agentName: string;
494
+ action: 'delegate' | 'handoff';
495
+ expectedOutput?: string;
496
+ constraints?: string[];
497
+ };
498
+ 'team.handoff.created': {
499
+ delegationId: string;
500
+ from: string;
501
+ to: string;
502
+ reason: string;
503
+ };
504
+ 'team.task.completed': {
505
+ delegationId: string;
506
+ agentName: string;
507
+ usage?: JsonObject;
508
+ };
509
+ 'team.task.failed': {
510
+ delegationId: string;
511
+ agentName?: string;
512
+ error: string;
513
+ };
514
+ 'team.merge.started': {
515
+ stepId: string;
516
+ width: number;
517
+ };
518
+ 'team.merge.completed': {
519
+ stepId: string;
520
+ };
521
+ 'team.merge.failed': {
522
+ stepId: string;
523
+ error: string;
524
+ };
525
+ 'team.run.paused': {
526
+ delegationId: string;
527
+ reason: 'child' | 'timer' | 'event';
528
+ childRunId?: string;
529
+ };
530
+ 'team.run.resumed': undefined;
531
+ 'team.run.completed': {
532
+ output: JsonValue;
533
+ usage?: JsonObject;
534
+ };
535
+ 'team.run.failed': {
536
+ error: string;
537
+ errorCode?: string;
538
+ retryable?: boolean;
539
+ source?: ToolEventSource;
540
+ };
541
+ 'team.run.cancelled': {
542
+ reason: 'aborted' | 'timeout' | 'approval_rejected';
543
+ };
544
+ }
545
+ interface AgentEventBase {
546
+ id: string;
547
+ sequence: number;
548
+ runId: RunId;
549
+ timestamp: string;
550
+ }
551
+ type AgentEvent<TType extends AgentEventType = AgentEventType> = { [TCurrent in TType]: AgentEventBase & {
552
+ type: TCurrent;
553
+ } & (AgentEventPayloads[TCurrent] extends undefined ? {
554
+ payload?: never;
555
+ } : {
556
+ payload: AgentEventPayloads[TCurrent];
557
+ }); }[TType];
558
+ //#endregion
559
+ export { ArtifactError as A, FileSystemArtifactStore as C, ArtifactCatalog as D, CatalogedArtifactStoreOptions as E, ArtifactStore as F, ArtifactStoreContext as I, ArtifactWrite as L, ArtifactId as M, ArtifactQuery as N, ArtifactContent as O, ArtifactRecord as P, artifactTenantId as R, InMemoryArtifactCatalog as S, CatalogedArtifactStore as T, S3ArtifactStore as _, AgentMessageRole as a, InMemoryArtifactStore as b, JsonPrimitive as c, PROVIDER_SCHEMA_UNSUPPORTED as d, RunId as f, ToolSpec as g, ToolEventSource as h, AgentMessage as i, ArtifactErrorCode as j, ArtifactDescriptor as k, JsonValue as l, ToolCall as m, AgentEventPayloads as n, ExecutionContext as o, SCHEMA_NOT_TRANSPORTABLE as p, AgentEventType as r, JsonObject as s, AgentEvent as t, PROVIDER_REASONING_UNSUPPORTED as u, S3ArtifactStoreOptions as v, FileSystemArtifactStoreOptions as w, InMemoryArtifactStoreOptions as x, S3ObjectClient as y, assertArtifactId as z };
@@ -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-DviHtsLo.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-Br-zPxZH.mjs";
2
2
  export { WorkflowAgentResult, WorkflowDefinition, WorkflowEventDefinition, WorkflowEventResult, WorkflowStep, WorkflowStepContext, WorkflowStepOptions, defineWorkflow };