@fevex/core 0.1.0-alpha.0 → 0.1.0-alpha.10

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 (52) hide show
  1. package/README.md +1110 -52
  2. package/dist/agents/index.d.mts +2 -23
  3. package/dist/agents/index.mjs +1 -1
  4. package/dist/artifacts/index.d.mts +2 -0
  5. package/dist/artifacts/index.mjs +2 -0
  6. package/dist/artifacts-gUzemET7.mjs +440 -0
  7. package/dist/channels/index.d.mts +2 -0
  8. package/dist/channels/index.mjs +192 -0
  9. package/dist/evals/index.d.mts +153 -0
  10. package/dist/evals/index.mjs +422 -0
  11. package/dist/fevex-_KOsOsB8.d.mts +129 -0
  12. package/dist/http/index.d.mts +150 -0
  13. package/dist/http/index.mjs +692 -0
  14. package/dist/index-26ilbzAs.d.mts +50 -0
  15. package/dist/index-B8EcvWeN.d.mts +103 -0
  16. package/dist/index-BEqYWean.d.mts +118 -0
  17. package/dist/index-Btth7rdL.d.mts +58 -0
  18. package/dist/index-CFzrvDQ0.d.mts +21 -0
  19. package/dist/index-CIHWc5V1.d.mts +116 -0
  20. package/dist/index-D7r0puBi.d.mts +64 -0
  21. package/dist/index-DHcfIfh-.d.mts +224 -0
  22. package/dist/index-DUhNa7IR.d.mts +73 -0
  23. package/dist/index-lCCFokc6.d.mts +617 -0
  24. package/dist/index.d.mts +39 -15
  25. package/dist/index.mjs +4962 -208
  26. package/dist/knowledge/index.d.mts +2 -0
  27. package/dist/knowledge/index.mjs +289 -0
  28. package/dist/model-stream-JQdHDDcj.mjs +131 -0
  29. package/dist/models/index.d.mts +2 -27
  30. package/dist/observability/index.d.mts +2 -0
  31. package/dist/observability/index.mjs +1 -0
  32. package/dist/policies/index.d.mts +2 -0
  33. package/dist/policies/index.mjs +6 -0
  34. package/dist/run-error-Cr17wPGH.mjs +23 -0
  35. package/dist/run-support-CmZ6Xo6H.mjs +162 -0
  36. package/dist/runtime/index.d.mts +2 -17
  37. package/dist/runtime/index.mjs +354 -1
  38. package/dist/sandbox/index.d.mts +2 -0
  39. package/dist/sandbox/index.mjs +147 -0
  40. package/dist/teams/index.d.mts +2 -0
  41. package/dist/teams/index.mjs +2 -0
  42. package/dist/teams-Ctz676G4.mjs +82 -0
  43. package/dist/testing/index.d.mts +40 -8
  44. package/dist/testing/index.mjs +668 -23
  45. package/dist/tools/index.d.mts +3 -31
  46. package/dist/tools/index.mjs +442 -2
  47. package/dist/types-CckDlhYo.d.mts +575 -0
  48. package/dist/workflows/index.d.mts +2 -0
  49. package/dist/workflows/index.mjs +6 -0
  50. package/package.json +43 -3
  51. package/dist/exact-definition-NHBBFlFR.d.mts +0 -4
  52. package/dist/index-D_RBJmVt.d.mts +0 -44
@@ -0,0 +1,129 @@
1
+ import { S as ConnectionDefinition, j as ToolDefinition, o as ToolEmbeddingCache } from "./index-DHcfIfh-.mjs";
2
+ import { t as ModelGateway } from "./index-D7r0puBi.mjs";
3
+ import { F as ArtifactStore, f as RunId, o as ExecutionContext, t as AgentEvent } from "./types-CckDlhYo.mjs";
4
+ import { r as Sandbox } from "./index-DUhNa7IR.mjs";
5
+ import { B as ResumeRunResolution, I as ListEventsOptions, J as RunRequest, O as CredentialStore, Q as Session, R as PurgeRunsOptions, Y as RunResult, Z as RunStore, a as ToolSearchOptions, d as ContextCompactionStats, dt as WorkflowRun, et as SessionId, q as RunRecord, r as ContextBudget, rt as TeamRun, t as AgentDefinition, u as ContextCompactionOptions, x as AgentRun, z as PurgeRunsResult } from "./index-lCCFokc6.mjs";
6
+ import { c as ContextProvider, f as MemoryStore } from "./index-CIHWc5V1.mjs";
7
+ import { i as ObservabilityStats, r as ObservabilityOptions } from "./index-BEqYWean.mjs";
8
+ import { r as PolicyDefinition } from "./index-CFzrvDQ0.mjs";
9
+ import { n as WorkflowDefinition } from "./index-Btth7rdL.mjs";
10
+ import { t as TeamDefinition } from "./index-26ilbzAs.mjs";
11
+ //#region src/fevex.d.ts
12
+ interface FevexAdmissionRequest {
13
+ kind: 'agent' | 'workflow' | 'team';
14
+ name: string;
15
+ request: RunRequest;
16
+ activeRuns: number;
17
+ activeTenantRuns: number;
18
+ }
19
+ /** Optional host-level admission controls applied before a top-level run starts. */
20
+ interface FevexAdmission {
21
+ /** Maximum concurrent top-level runs in this runtime. */
22
+ maxActiveRuns?: number;
23
+ /** Maximum concurrent top-level runs for one tenant. */
24
+ maxActiveRunsPerTenant?: number;
25
+ /** Defaults to a non-empty `context.attributes.tenantId` string. */
26
+ tenantKey?: (context?: ExecutionContext) => string | undefined;
27
+ /** Custom admission check, called after the built-in limits. */
28
+ authorize?: (request: FevexAdmissionRequest) => boolean | Promise<boolean>;
29
+ }
30
+ interface FevexShutdownOptions {
31
+ /**
32
+ * Maximum time to wait for active runs before cancelling them. Defaults to
33
+ * 30 seconds. Use `0` to cancel immediately. If the deadline expires,
34
+ * shutdown allows up to 5 additional seconds for forced cancellation and the
35
+ * final trace flush.
36
+ */
37
+ timeoutMs?: number;
38
+ }
39
+ interface FevexShutdownResult {
40
+ /** Runs that were still active when the grace period expired. */
41
+ cancelledRunIds: RunId[];
42
+ /** True when the grace deadline expired before all active runs finished. */
43
+ timedOut: boolean;
44
+ /** Error surfaced while flushing pending traces, if any. */
45
+ exportError?: unknown;
46
+ /** Observability counters after the shutdown flush. */
47
+ observability: ObservabilityStats;
48
+ }
49
+ interface FevexLimits {
50
+ /**
51
+ * Maximum non-control events persisted for one run. Control events such as
52
+ * pause, resume, approval and terminal transitions are always persisted.
53
+ */
54
+ maxEventsPerRun?: number;
55
+ }
56
+ /** Provider-neutral definitions and adapters used to create one Fevex runtime. */
57
+ interface FevexConfig {
58
+ models: Record<string, ModelGateway>;
59
+ agents: AgentDefinition[];
60
+ workflows?: WorkflowDefinition[];
61
+ teams?: TeamDefinition[];
62
+ tools?: ToolDefinition[];
63
+ connections?: ConnectionDefinition[];
64
+ contextProviders?: ContextProvider[];
65
+ /** Default context budget for agents that do not declare one. */
66
+ contextBudget?: ContextBudget;
67
+ /** Optional context compactor and token estimator. */
68
+ compaction?: ContextCompactionOptions;
69
+ /** Default on-demand tool search for agents that do not declare one. */
70
+ toolSearch?: ToolSearchOptions;
71
+ /** Optional durable cache for semantic tool embeddings. */
72
+ toolSearchCache?: ToolEmbeddingCache;
73
+ memoryStore?: MemoryStore;
74
+ runStore?: RunStore;
75
+ credentialStore?: CredentialStore;
76
+ sandbox?: Sandbox;
77
+ /** Optional artifact store exposed to tools as `context.artifacts`. */
78
+ artifacts?: ArtifactStore;
79
+ policies?: PolicyDefinition[];
80
+ onEvent?: (event: AgentEvent) => void;
81
+ observability?: ObservabilityOptions;
82
+ admission?: FevexAdmission;
83
+ limits?: FevexLimits;
84
+ }
85
+ interface Fevex {
86
+ startAgent<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): Promise<AgentRun<TOutput>>;
87
+ runAgent<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): Promise<RunResult<TOutput>>;
88
+ streamAgent<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): AsyncIterable<AgentEvent>;
89
+ startWorkflow<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): Promise<WorkflowRun<TOutput>>;
90
+ runWorkflow<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): Promise<RunResult<TOutput>>;
91
+ startTeam<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): Promise<TeamRun<TOutput>>;
92
+ runTeam<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): Promise<RunResult<TOutput>>;
93
+ streamTeam<TInput = unknown, TOutput = unknown>(name: string, request: RunRequest<TInput, TOutput>): AsyncIterable<AgentEvent>;
94
+ getTeamRun<TOutput = unknown>(runId: RunId): Promise<TeamRun<TOutput> | undefined>;
95
+ getRun<TOutput = unknown>(runId: RunId): Promise<RunRecord<TOutput> | undefined>;
96
+ listEvents(runId: RunId, options?: ListEventsOptions): Promise<AgentEvent[]>;
97
+ cancelRun(runId: RunId): Promise<boolean>;
98
+ resumeRun<TOutput = unknown>(runId: RunId, resolution: ResumeRunResolution): Promise<RunRecord<TOutput>>;
99
+ recoverRun<TOutput = unknown>(runId: RunId, options: {
100
+ actor: {
101
+ id: string;
102
+ type?: string;
103
+ };
104
+ }): Promise<RunRecord<TOutput>>;
105
+ purgeRuns(options?: PurgeRunsOptions): Promise<PurgeRunsResult>;
106
+ compactSession(sessionId: SessionId, summary: string): Promise<Session>;
107
+ /** Waits for queued exports and rejects with failures accumulated since the previous flush. */
108
+ flushObservability(options?: {
109
+ timeoutMs?: number;
110
+ }): Promise<void>;
111
+ /** Cumulative trace export counters for this runtime. */
112
+ getObservabilityStats(): ObservabilityStats;
113
+ /** Cumulative context compaction counters for this runtime. */
114
+ getCompactionStats(): ContextCompactionStats;
115
+ /**
116
+ * Stops admitting new work, drains or cancels active runs, and flushes trace
117
+ * exports. The host still owns closing its stores and external adapters.
118
+ */
119
+ shutdown(options?: FevexShutdownOptions): Promise<FevexShutdownResult>;
120
+ }
121
+ /**
122
+ * Validates a configuration snapshot and creates an isolated runtime.
123
+ *
124
+ * The runtime does not own external adapters; callers remain responsible for
125
+ * closing model, connection, store, and exporter resources they provide.
126
+ */
127
+ declare function createFevex(config: FevexConfig): Fevex;
128
+ //#endregion
129
+ export { FevexLimits as a, createFevex as c, FevexConfig as i, FevexAdmission as n, FevexShutdownOptions as o, FevexAdmissionRequest as r, FevexShutdownResult as s, Fevex as t };
@@ -0,0 +1,150 @@
1
+ import { c as ReasoningEffort } from "../index-D7r0puBi.mjs";
2
+ import { D as ArtifactCatalog, F as ArtifactStore, f as RunId, k as ArtifactDescriptor, l as JsonValue, o as ExecutionContext, t as AgentEvent } from "../types-CckDlhYo.mjs";
3
+ import { dt as WorkflowRun, et as SessionId, q as RunRecord, rt as TeamRun, x as AgentRun } from "../index-lCCFokc6.mjs";
4
+ import { t as Fevex } from "../fevex-_KOsOsB8.mjs";
5
+ //#region src/http/protocol.d.ts
6
+ declare const FEVEX_HTTP_PROTOCOL_VERSION = "3";
7
+ declare const FEVEX_HTTP_PROTOCOL_VERSION_HEADER = "Fevex-Protocol-Version";
8
+ interface StartRunHttpRequest<TInput extends JsonValue = JsonValue> {
9
+ input: TInput;
10
+ model?: string;
11
+ reasoning?: ReasoningEffort;
12
+ sessionId?: SessionId;
13
+ /** Maximum wall-clock time for the run, including time spent paused. */
14
+ deadlineMs?: number;
15
+ }
16
+ type ResumeRunHttpRequest = {
17
+ type: 'elicitation';
18
+ requestId: string;
19
+ value: JsonValue;
20
+ } | {
21
+ type: 'approval';
22
+ approvalId: string;
23
+ decision: 'approve' | 'reject';
24
+ } | {
25
+ type: 'tool_execution';
26
+ toolCallId: string;
27
+ decision: 'use_output';
28
+ output: JsonValue;
29
+ } | {
30
+ type: 'tool_execution';
31
+ toolCallId: string;
32
+ decision: 'retry';
33
+ } | {
34
+ type: 'timer';
35
+ } | {
36
+ type: 'event';
37
+ eventName: string;
38
+ payload?: JsonValue;
39
+ };
40
+ /** RFC 9457-compatible problem returned by the Fevex HTTP protocol. */
41
+ interface FevexProblemDetails {
42
+ type: string;
43
+ title: string;
44
+ status: number;
45
+ code: string;
46
+ detail?: string;
47
+ instance?: string;
48
+ }
49
+ interface FevexHttpHandlerContext {
50
+ context?: ExecutionContext;
51
+ }
52
+ /** Host-facing resource access check. */
53
+ type FevexHttpAccess = {
54
+ action: 'start';
55
+ kind: 'agent' | 'workflow' | 'team';
56
+ name: string;
57
+ sessionId?: SessionId;
58
+ context?: ExecutionContext;
59
+ } | {
60
+ action: 'read' | 'observe' | 'cancel' | 'resume' | 'recover';
61
+ runId: RunId;
62
+ context?: ExecutionContext;
63
+ };
64
+ /** Host-facing artifact access check. */
65
+ type FevexArtifactAccess = {
66
+ action: 'read' | 'delete';
67
+ kind: 'artifact';
68
+ artifactId: string;
69
+ context?: ExecutionContext;
70
+ } | {
71
+ action: 'read';
72
+ kind: 'artifacts';
73
+ runId: RunId;
74
+ context?: ExecutionContext;
75
+ };
76
+ interface FevexHttpHandlerOptions {
77
+ fevex: Fevex;
78
+ pollIntervalMs?: number;
79
+ /** Events per SSE read (default 100, maximum 1000). */
80
+ eventPageSize?: number;
81
+ /** Maximum concurrent SSE streams (default unlimited). */
82
+ maxConnections?: number;
83
+ /**
84
+ * Authorizes a resource operation before the handler reads or mutates a run,
85
+ * or starts a run (new or existing session). Return false for a 403 response.
86
+ * Omit to preserve the host's existing trusted-network behavior.
87
+ */
88
+ authorize?: (access: FevexHttpAccess) => boolean | Promise<boolean>;
89
+ /**
90
+ * Byte store used by the artifact routes. When omitted, artifact routes
91
+ * return 501.
92
+ */
93
+ artifacts?: ArtifactStore;
94
+ /**
95
+ * Metadata catalog used to list artifacts for a run. When omitted, the
96
+ * run-artifact listing route returns 501.
97
+ */
98
+ artifactCatalog?: ArtifactCatalog;
99
+ /**
100
+ * Authorizes artifact reads, listings and deletions. Omit to preserve the
101
+ * host's existing trusted-network behavior.
102
+ */
103
+ authorizeArtifact?: (access: FevexArtifactAccess) => boolean | Promise<boolean>;
104
+ /**
105
+ * Called after a run starts so the host can persist run and session ownership.
106
+ * If it throws, the handler cancels the new run and returns 500. A process
107
+ * crash between start and this callback leaves the run unowned; hosts must
108
+ * treat unowned runs as inaccessible. Runs created outside the HTTP handler
109
+ * are not reported.
110
+ */
111
+ onRunStarted?: (run: RunRecord, context?: ExecutionContext) => void | Promise<void>;
112
+ onError?: (error: unknown, problem: FevexProblemDetails) => void;
113
+ }
114
+ type FevexHttpHandler = (request: Request, context?: FevexHttpHandlerContext) => Promise<Response>;
115
+ interface FevexHttpClientOptions {
116
+ baseUrl: string;
117
+ fetch?: FevexHttpFetch;
118
+ }
119
+ type FevexHttpFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
120
+ interface ObserveRunOptions {
121
+ after?: AgentEvent['id'];
122
+ signal?: AbortSignal;
123
+ }
124
+ interface FevexHttpClient {
125
+ startRun<TInput extends JsonValue = JsonValue, TOutput = JsonValue>(agentName: string, request: StartRunHttpRequest<TInput>): Promise<AgentRun<TOutput>>;
126
+ startWorkflow<TInput extends JsonValue = JsonValue, TOutput = JsonValue>(workflowName: string, request: StartRunHttpRequest<TInput>): Promise<WorkflowRun<TOutput>>;
127
+ startTeam<TInput extends JsonValue = JsonValue, TOutput = JsonValue>(teamName: string, request: StartRunHttpRequest<TInput>): Promise<TeamRun<TOutput>>;
128
+ getRun<TOutput = JsonValue>(runId: string): Promise<RunRecord<TOutput>>;
129
+ observeRun(runId: string, options?: ObserveRunOptions): AsyncIterable<AgentEvent>;
130
+ resumeRun<TOutput = JsonValue>(runId: string, request: ResumeRunHttpRequest): Promise<RunRecord<TOutput>>;
131
+ recoverRun<TOutput = JsonValue>(runId: string): Promise<RunRecord<TOutput>>;
132
+ cancelRun(runId: string): Promise<void>;
133
+ getArtifact(artifactId: string): Promise<Response>;
134
+ listArtifacts(runId: string): Promise<ArtifactDescriptor[]>;
135
+ deleteArtifact(artifactId: string): Promise<void>;
136
+ }
137
+ //#endregion
138
+ //#region src/http/transport.d.ts
139
+ /** Exposes a Fevex instance through the versioned HTTP protocol. */
140
+ declare function createFevexHttpHandler(options: FevexHttpHandlerOptions): FevexHttpHandler;
141
+ declare class FevexHttpError extends Error {
142
+ readonly problem: FevexProblemDetails;
143
+ readonly name = "FevexHttpError";
144
+ constructor(problem: FevexProblemDetails);
145
+ get status(): number;
146
+ get code(): string;
147
+ }
148
+ declare function createFevexHttpClient(options: FevexHttpClientOptions): FevexHttpClient;
149
+ //#endregion
150
+ export { FEVEX_HTTP_PROTOCOL_VERSION, FEVEX_HTTP_PROTOCOL_VERSION_HEADER, FevexArtifactAccess, FevexHttpAccess, FevexHttpClient, FevexHttpClientOptions, FevexHttpError, FevexHttpFetch, FevexHttpHandler, FevexHttpHandlerContext, FevexHttpHandlerOptions, FevexProblemDetails, ObserveRunOptions, ResumeRunHttpRequest, StartRunHttpRequest, createFevexHttpClient, createFevexHttpHandler };