@fevex/core 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +349 -49
- package/dist/agents/index.d.mts +1 -22
- package/dist/evals/index.d.mts +145 -0
- package/dist/evals/index.mjs +419 -0
- package/dist/fevex-Dz6GBz9o.d.mts +32 -0
- package/dist/index-BzxHfyYV.d.mts +23 -0
- package/dist/index-CZGyhNIQ.d.mts +47 -0
- package/dist/index-C_Zpr13f.d.mts +124 -0
- package/dist/index-DGWOGXzc.d.mts +181 -0
- package/dist/index-QTkd6a7C.d.mts +20 -0
- package/dist/index-ojCY3lwm.d.mts +79 -0
- package/dist/index.d.mts +27 -15
- package/dist/index.mjs +1444 -197
- package/dist/model-stream-u2xMsEaf.mjs +251 -0
- package/dist/models/index.d.mts +24 -5
- package/dist/observability/index.d.mts +2 -0
- package/dist/observability/index.mjs +1 -0
- package/dist/policies/index.d.mts +2 -0
- package/dist/policies/index.mjs +6 -0
- package/dist/runtime/index.d.mts +2 -17
- package/dist/runtime/index.mjs +92 -1
- package/dist/testing/index.d.mts +7 -5
- package/dist/testing/index.mjs +172 -11
- package/dist/tools/index.d.mts +3 -31
- package/package.json +15 -3
- package/dist/index-D_RBJmVt.d.mts +0 -44
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { f as RunId, i as AgentMessage, l as JsonValue, o as ExecutionContext, t as AgentEvent } from "./index-C_Zpr13f.mjs";
|
|
2
|
+
import { ModelUsage } from "./models/index.mjs";
|
|
3
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
//#region src/runtime/index.d.ts
|
|
5
|
+
type SessionId = string;
|
|
6
|
+
type RunStatus = 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
7
|
+
interface ApprovalRequest {
|
|
8
|
+
id: string;
|
|
9
|
+
toolCallId: string;
|
|
10
|
+
toolName: string;
|
|
11
|
+
input: JsonValue;
|
|
12
|
+
risk: 'read' | 'write' | 'sensitive' | 'destructive';
|
|
13
|
+
requestedAt: string;
|
|
14
|
+
}
|
|
15
|
+
type RunPause = {
|
|
16
|
+
type: 'approval';
|
|
17
|
+
approval: ApprovalRequest;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'tool_execution_unknown';
|
|
20
|
+
toolCallId: string;
|
|
21
|
+
toolName: string;
|
|
22
|
+
input: JsonValue;
|
|
23
|
+
};
|
|
24
|
+
interface ApprovalResolution {
|
|
25
|
+
type: 'approval';
|
|
26
|
+
approvalId: string;
|
|
27
|
+
decision: 'approve' | 'reject';
|
|
28
|
+
actor: {
|
|
29
|
+
id: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
type ToolExecutionResolution = {
|
|
34
|
+
type: 'tool_execution';
|
|
35
|
+
toolCallId: string;
|
|
36
|
+
decision: 'use_output';
|
|
37
|
+
output: JsonValue;
|
|
38
|
+
actor: {
|
|
39
|
+
id: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
type: 'tool_execution';
|
|
44
|
+
toolCallId: string;
|
|
45
|
+
decision: 'retry';
|
|
46
|
+
actor: {
|
|
47
|
+
id: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type ResumeRunResolution = ApprovalResolution | ToolExecutionResolution;
|
|
52
|
+
interface AgentRun<TOutput = JsonValue> {
|
|
53
|
+
id: RunId;
|
|
54
|
+
sessionId: SessionId;
|
|
55
|
+
agentName: string;
|
|
56
|
+
status: RunStatus;
|
|
57
|
+
revision: number;
|
|
58
|
+
pause?: RunPause;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
output?: TOutput;
|
|
62
|
+
error?: string;
|
|
63
|
+
usage?: ModelUsage;
|
|
64
|
+
}
|
|
65
|
+
interface Session {
|
|
66
|
+
id: SessionId;
|
|
67
|
+
history: AgentMessage[];
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
70
|
+
}
|
|
71
|
+
interface ListEventsOptions {
|
|
72
|
+
after?: AgentEvent['id'];
|
|
73
|
+
}
|
|
74
|
+
interface RunStore {
|
|
75
|
+
getRun(runId: RunId): Promise<AgentRun | undefined>;
|
|
76
|
+
saveRun(run: AgentRun): Promise<void>;
|
|
77
|
+
getSession(sessionId: SessionId): Promise<Session | undefined>;
|
|
78
|
+
saveSession(session: Session): Promise<void>;
|
|
79
|
+
appendEvent(event: AgentEvent): Promise<void>;
|
|
80
|
+
listEvents(runId: RunId, options?: ListEventsOptions): Promise<AgentEvent[]>;
|
|
81
|
+
}
|
|
82
|
+
interface CredentialStore {
|
|
83
|
+
resolve(input: {
|
|
84
|
+
name: string;
|
|
85
|
+
namespace?: string;
|
|
86
|
+
actor?: {
|
|
87
|
+
id: string;
|
|
88
|
+
type?: string;
|
|
89
|
+
};
|
|
90
|
+
}): Promise<string | undefined>;
|
|
91
|
+
}
|
|
92
|
+
interface PendingToolExecution {
|
|
93
|
+
call: {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
input: JsonValue;
|
|
97
|
+
};
|
|
98
|
+
input: JsonValue;
|
|
99
|
+
idempotencyKey: string;
|
|
100
|
+
attempt: number;
|
|
101
|
+
}
|
|
102
|
+
interface RunCheckpoint {
|
|
103
|
+
runId: RunId;
|
|
104
|
+
definitionHash: string;
|
|
105
|
+
messages: AgentMessage[];
|
|
106
|
+
inputContent: string;
|
|
107
|
+
context?: ExecutionContext;
|
|
108
|
+
usage?: ModelUsage;
|
|
109
|
+
providerState?: JsonValue;
|
|
110
|
+
step: number;
|
|
111
|
+
toolCallCount: number;
|
|
112
|
+
seenToolCallIds: string[];
|
|
113
|
+
pendingTools: PendingToolExecution[];
|
|
114
|
+
pendingIndex: number;
|
|
115
|
+
}
|
|
116
|
+
type ToolExecutionStatus = 'started' | 'completed' | 'failed' | 'unknown';
|
|
117
|
+
interface ToolExecutionRecord {
|
|
118
|
+
runId: RunId;
|
|
119
|
+
toolCallId: string;
|
|
120
|
+
toolName: string;
|
|
121
|
+
input: JsonValue;
|
|
122
|
+
status: ToolExecutionStatus;
|
|
123
|
+
attempt: number;
|
|
124
|
+
idempotencyKey: string;
|
|
125
|
+
output?: JsonValue;
|
|
126
|
+
error?: string;
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
}
|
|
129
|
+
interface RunLease {
|
|
130
|
+
runId: RunId;
|
|
131
|
+
ownerId: string;
|
|
132
|
+
expiresAt: string;
|
|
133
|
+
}
|
|
134
|
+
interface ExecutionCommit {
|
|
135
|
+
expectedRevision: number;
|
|
136
|
+
run: AgentRun;
|
|
137
|
+
checkpoint?: RunCheckpoint | null;
|
|
138
|
+
session?: Session;
|
|
139
|
+
toolExecution?: ToolExecutionRecord;
|
|
140
|
+
events?: AgentEvent[];
|
|
141
|
+
}
|
|
142
|
+
interface DurableRunStore extends RunStore {
|
|
143
|
+
getCheckpoint(runId: RunId): Promise<RunCheckpoint | undefined>;
|
|
144
|
+
getToolExecution(runId: RunId, toolCallId: string): Promise<ToolExecutionRecord | undefined>;
|
|
145
|
+
commitExecution(commit: ExecutionCommit): Promise<boolean>;
|
|
146
|
+
acquireLease(lease: RunLease): Promise<boolean>;
|
|
147
|
+
renewLease(lease: RunLease): Promise<boolean>;
|
|
148
|
+
releaseLease(runId: RunId, ownerId: string): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
declare function isDurableRunStore(store: RunStore): store is DurableRunStore;
|
|
151
|
+
declare class InMemoryRunStore implements DurableRunStore {
|
|
152
|
+
#private;
|
|
153
|
+
getRun(runId: RunId): Promise<AgentRun | undefined>;
|
|
154
|
+
saveRun(run: AgentRun): Promise<void>;
|
|
155
|
+
getSession(sessionId: SessionId): Promise<Session | undefined>;
|
|
156
|
+
saveSession(session: Session): Promise<void>;
|
|
157
|
+
appendEvent(event: AgentEvent): Promise<void>;
|
|
158
|
+
listEvents(runId: RunId, options?: ListEventsOptions): Promise<AgentEvent[]>;
|
|
159
|
+
getCheckpoint(runId: RunId): Promise<RunCheckpoint | undefined>;
|
|
160
|
+
getToolExecution(runId: RunId, toolCallId: string): Promise<ToolExecutionRecord | undefined>;
|
|
161
|
+
commitExecution(commit: ExecutionCommit): Promise<boolean>;
|
|
162
|
+
acquireLease(lease: RunLease): Promise<boolean>;
|
|
163
|
+
renewLease(lease: RunLease): Promise<boolean>;
|
|
164
|
+
releaseLease(runId: RunId, ownerId: string): Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
interface RunRequest<TInput = unknown, TOutput = unknown> {
|
|
167
|
+
input: TInput;
|
|
168
|
+
context?: ExecutionContext;
|
|
169
|
+
outputSchema?: StandardSchemaV1<unknown, TOutput>;
|
|
170
|
+
sessionId?: SessionId;
|
|
171
|
+
signal?: AbortSignal;
|
|
172
|
+
}
|
|
173
|
+
interface RunResult<TOutput = unknown> {
|
|
174
|
+
runId: RunId;
|
|
175
|
+
sessionId: SessionId;
|
|
176
|
+
output: TOutput;
|
|
177
|
+
events?: AgentEvent[];
|
|
178
|
+
usage?: ModelUsage;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { isDurableRunStore as C, ToolExecutionStatus as S, RunStore as _, DurableRunStore as a, ToolExecutionRecord as b, ListEventsOptions as c, RunCheckpoint as d, RunLease as f, RunStatus as g, RunResult as h, CredentialStore as i, PendingToolExecution as l, RunRequest as m, ApprovalRequest as n, ExecutionCommit as o, RunPause as p, ApprovalResolution as r, InMemoryRunStore as s, AgentRun as t, ResumeRunResolution as u, Session as v, ToolExecutionResolution as x, SessionId as y };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { f as RunId, l as JsonValue, o as ExecutionContext } from "./index-C_Zpr13f.mjs";
|
|
2
|
+
import { s as ToolRisk } from "./index-CZGyhNIQ.mjs";
|
|
3
|
+
//#region src/policies/index.d.ts
|
|
4
|
+
type PolicyDecision = 'allow' | 'deny' | 'require_approval';
|
|
5
|
+
interface PolicyAuthorization {
|
|
6
|
+
runId: RunId;
|
|
7
|
+
agentName: string;
|
|
8
|
+
toolName: string;
|
|
9
|
+
risk: ToolRisk;
|
|
10
|
+
input: JsonValue;
|
|
11
|
+
action: 'tool.execute' | 'approval.resolve';
|
|
12
|
+
context?: ExecutionContext;
|
|
13
|
+
}
|
|
14
|
+
interface PolicyDefinition {
|
|
15
|
+
name: string;
|
|
16
|
+
authorize(input: PolicyAuthorization): PolicyDecision | Promise<PolicyDecision>;
|
|
17
|
+
}
|
|
18
|
+
declare function definePolicy<T extends PolicyDefinition>(policy: T): T;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { definePolicy as i, PolicyDecision as n, PolicyDefinition as r, PolicyAuthorization as t };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { f as RunId, l as JsonValue, s as JsonObject } from "./index-C_Zpr13f.mjs";
|
|
2
|
+
import { ModelMetadata, ModelUsage } from "./models/index.mjs";
|
|
3
|
+
import { y as SessionId } from "./index-DGWOGXzc.mjs";
|
|
4
|
+
//#region src/observability/index.d.ts
|
|
5
|
+
type TraceStatus = 'completed' | 'failed' | 'cancelled';
|
|
6
|
+
type TraceSpanKind = 'model' | 'tool';
|
|
7
|
+
type TraceContentKind = 'run.output' | 'model.output' | 'error.message';
|
|
8
|
+
interface TraceCost {
|
|
9
|
+
amount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
}
|
|
12
|
+
interface TraceContent {
|
|
13
|
+
kind: TraceContentKind;
|
|
14
|
+
value: JsonValue;
|
|
15
|
+
}
|
|
16
|
+
interface TraceAnnotation {
|
|
17
|
+
name: string;
|
|
18
|
+
timestamp: string;
|
|
19
|
+
attributes?: JsonObject;
|
|
20
|
+
}
|
|
21
|
+
interface TraceSpan {
|
|
22
|
+
id: string;
|
|
23
|
+
parentId: string;
|
|
24
|
+
kind: TraceSpanKind;
|
|
25
|
+
name: string;
|
|
26
|
+
startedAt: string;
|
|
27
|
+
endedAt: string;
|
|
28
|
+
durationMs: number;
|
|
29
|
+
status: TraceStatus;
|
|
30
|
+
attributes: JsonObject;
|
|
31
|
+
annotations: TraceAnnotation[];
|
|
32
|
+
usage?: ModelUsage;
|
|
33
|
+
cost?: TraceCost;
|
|
34
|
+
content?: TraceContent[];
|
|
35
|
+
}
|
|
36
|
+
interface RunTrace {
|
|
37
|
+
schemaVersion: '1';
|
|
38
|
+
traceId: string;
|
|
39
|
+
runId: RunId;
|
|
40
|
+
sessionId: SessionId;
|
|
41
|
+
agentName: string;
|
|
42
|
+
modelRegistryName: string;
|
|
43
|
+
model?: ModelMetadata;
|
|
44
|
+
startedAt: string;
|
|
45
|
+
endedAt: string;
|
|
46
|
+
durationMs: number;
|
|
47
|
+
status: TraceStatus;
|
|
48
|
+
attributes: JsonObject;
|
|
49
|
+
annotations: TraceAnnotation[];
|
|
50
|
+
spans: TraceSpan[];
|
|
51
|
+
usage?: ModelUsage;
|
|
52
|
+
cost?: TraceCost;
|
|
53
|
+
content?: TraceContent[];
|
|
54
|
+
}
|
|
55
|
+
interface CostCalculatorInput {
|
|
56
|
+
modelRegistryName: string;
|
|
57
|
+
model?: ModelMetadata;
|
|
58
|
+
usage: ModelUsage;
|
|
59
|
+
}
|
|
60
|
+
type CostCalculator = (input: CostCalculatorInput) => TraceCost | undefined;
|
|
61
|
+
interface TraceRedactorInput {
|
|
62
|
+
kind: TraceContentKind;
|
|
63
|
+
value: JsonValue;
|
|
64
|
+
}
|
|
65
|
+
type TraceRedactor = (input: TraceRedactorInput) => JsonValue | undefined;
|
|
66
|
+
interface TraceContentPolicy {
|
|
67
|
+
include: readonly TraceContentKind[];
|
|
68
|
+
redact?: TraceRedactor;
|
|
69
|
+
}
|
|
70
|
+
interface TraceExporter {
|
|
71
|
+
export(trace: Readonly<RunTrace>): void | Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
interface ObservabilityOptions {
|
|
74
|
+
exporters: readonly TraceExporter[];
|
|
75
|
+
calculateCost?: CostCalculator;
|
|
76
|
+
content?: TraceContentPolicy;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { TraceAnnotation as a, TraceContentPolicy as c, TraceRedactor as d, TraceRedactorInput as f, TraceStatus as h, RunTrace as i, TraceCost as l, TraceSpanKind as m, CostCalculatorInput as n, TraceContent as o, TraceSpan as p, ObservabilityOptions as r, TraceContentKind as s, CostCalculator as t, TraceExporter as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { ModelGateway,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { a as AgentMessageRole, c as JsonPrimitive, d as PROVIDER_SCHEMA_UNSUPPORTED, f as RunId, h as ToolSpec, i as AgentMessage, l as JsonValue, m as ToolCall, n as AgentEventPayloads, o as ExecutionContext, p as SCHEMA_NOT_TRANSPORTABLE, r as AgentEventType, s as JsonObject, t as AgentEvent, u as PROVIDER_REASONING_UNSUPPORTED } from "./index-C_Zpr13f.mjs";
|
|
2
|
+
import { ModelGateway, ModelInput, ModelMetadata, ModelRef, ModelResult, ModelStreamEvent, ModelUsage, ReasoningEffort } from "./models/index.mjs";
|
|
3
|
+
import { n as AgentLimits, r as defineAgent, t as AgentDefinition } from "./index-BzxHfyYV.mjs";
|
|
4
|
+
import { C as isDurableRunStore, S as ToolExecutionStatus, _ as RunStore, a as DurableRunStore, b as ToolExecutionRecord, c as ListEventsOptions, d as RunCheckpoint, f as RunLease, g as RunStatus, h as RunResult, i as CredentialStore, l as PendingToolExecution, m as RunRequest, n as ApprovalRequest, o as ExecutionCommit, p as RunPause, r as ApprovalResolution, s as InMemoryRunStore, t as AgentRun, u as ResumeRunResolution, v as Session, x as ToolExecutionResolution, y as SessionId } from "./index-DGWOGXzc.mjs";
|
|
5
|
+
import { a as ToolResult, c as defineTool, i as ToolIdempotency, l as toToolSpec, n as ToolDefinition, o as ToolRetryPolicy, r as ToolExecutionContext, s as ToolRisk, t as ToolApproval } from "./index-CZGyhNIQ.mjs";
|
|
6
|
+
import { i as definePolicy, n as PolicyDecision, r as PolicyDefinition, t as PolicyAuthorization } from "./index-QTkd6a7C.mjs";
|
|
7
|
+
import { n as FevexConfig, r as createFevex, t as Fevex } from "./fevex-Dz6GBz9o.mjs";
|
|
8
|
+
//#region src/configuration-error.d.ts
|
|
9
|
+
type FevexConfigurationErrorCode = 'INVALID_CONFIG' | 'INVALID_MODEL' | 'INVALID_AGENT' | 'INVALID_TOOL' | 'DUPLICATE_AGENT' | 'DUPLICATE_TOOL' | 'MISSING_MODEL' | 'MISSING_TOOL';
|
|
10
|
+
declare class FevexConfigurationError extends Error {
|
|
11
|
+
readonly code: FevexConfigurationErrorCode;
|
|
12
|
+
constructor(code: FevexConfigurationErrorCode, message: string);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/run-error.d.ts
|
|
16
|
+
type FevexRunErrorCode = 'DURABLE_STORE_REQUIRED' | 'RUN_CONFLICT' | 'RUN_NOT_RESUMABLE' | 'RUN_DEFINITION_CHANGED' | 'POLICY_DENIED' | 'CREDENTIAL_NOT_FOUND' | 'APPROVAL_INVALID' | 'RUN_PAUSED' | 'TOOL_EXECUTION_UNKNOWN';
|
|
17
|
+
declare class FevexRunError extends Error {
|
|
18
|
+
readonly code: FevexRunErrorCode;
|
|
19
|
+
readonly runId?: RunId | undefined;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
constructor(code: FevexRunErrorCode, message: string, runId?: RunId | undefined, options?: ErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
declare class RunPausedError extends FevexRunError {
|
|
24
|
+
readonly runId: RunId;
|
|
25
|
+
readonly pause: RunPause;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
constructor(runId: RunId, pause: RunPause);
|
|
15
28
|
}
|
|
16
|
-
declare function createFevex(config: FevexConfig): Fevex;
|
|
17
29
|
//#endregion
|
|
18
|
-
export { AgentDefinition, AgentEvent, AgentEventType, AgentLimits, AgentMessage, AgentMessageRole, ExecutionContext, Fevex, FevexConfig, JsonObject, JsonPrimitive, JsonValue, ModelGateway,
|
|
30
|
+
export { AgentDefinition, AgentEvent, AgentEventPayloads, AgentEventType, AgentLimits, AgentMessage, AgentMessageRole, AgentRun, ApprovalRequest, ApprovalResolution, CredentialStore, DurableRunStore, ExecutionCommit, ExecutionContext, Fevex, FevexConfig, FevexConfigurationError, FevexConfigurationErrorCode, FevexRunError, FevexRunErrorCode, InMemoryRunStore, JsonObject, JsonPrimitive, JsonValue, ListEventsOptions, ModelGateway, ModelInput, ModelMetadata, ModelRef, ModelResult, ModelStreamEvent, ModelUsage, PROVIDER_REASONING_UNSUPPORTED, PROVIDER_SCHEMA_UNSUPPORTED, PendingToolExecution, PolicyAuthorization, PolicyDecision, PolicyDefinition, ReasoningEffort, ResumeRunResolution, RunCheckpoint, RunId, RunLease, RunPause, RunPausedError, RunRequest, RunResult, RunStatus, RunStore, SCHEMA_NOT_TRANSPORTABLE, Session, SessionId, ToolApproval, ToolCall, ToolDefinition, ToolExecutionContext, ToolExecutionRecord, ToolExecutionResolution, ToolExecutionStatus, ToolIdempotency, ToolResult, ToolRetryPolicy, ToolRisk, ToolSpec, createFevex, defineAgent, definePolicy, defineTool, isDurableRunStore, toToolSpec };
|