@fevex/core 0.1.0-alpha.0 → 0.1.0-alpha.2
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 +770 -52
- package/dist/agents/index.d.mts +1 -22
- package/dist/agents/index.mjs +1 -1
- package/dist/channels/index.d.mts +2 -0
- package/dist/channels/index.mjs +150 -0
- package/dist/evals/index.d.mts +153 -0
- package/dist/evals/index.mjs +422 -0
- package/dist/fevex-Ddyi6z6L.d.mts +60 -0
- package/dist/http/index.d.mts +90 -0
- package/dist/http/index.mjs +470 -0
- package/dist/index-B4PIkqOU.d.mts +80 -0
- package/dist/index-Bg9rr8Qe.d.mts +50 -0
- package/dist/index-Bgcxgy66.d.mts +82 -0
- package/dist/index-CTIwrVf9.d.mts +51 -0
- package/dist/index-CqOjvtQ9.d.mts +132 -0
- package/dist/index-CrOId2px.d.mts +66 -0
- package/dist/index-DeXUtyd9.d.mts +70 -0
- package/dist/index-DviHtsLo.d.mts +58 -0
- package/dist/index-Dx_LotWZ.d.mts +425 -0
- package/dist/index-dkFyTNh4.d.mts +21 -0
- package/dist/index.d.mts +39 -15
- package/dist/index.mjs +3505 -194
- package/dist/knowledge/index.d.mts +2 -0
- package/dist/knowledge/index.mjs +89 -0
- package/dist/model-stream-u2xMsEaf.mjs +251 -0
- package/dist/models/index.d.mts +2 -27
- 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/run-error-Cr17wPGH.mjs +23 -0
- package/dist/runtime/index.d.mts +2 -17
- package/dist/runtime/index.mjs +141 -1
- package/dist/sandbox/index.d.mts +2 -0
- package/dist/sandbox/index.mjs +122 -0
- package/dist/teams/index.d.mts +2 -0
- package/dist/teams/index.mjs +2 -0
- package/dist/teams-Ctz676G4.mjs +82 -0
- package/dist/testing/index.d.mts +34 -8
- package/dist/testing/index.mjs +572 -23
- package/dist/tools/index.d.mts +3 -31
- package/dist/tools/index.mjs +222 -2
- package/dist/types-CuoRx12Q.d.mts +333 -0
- package/dist/workflows/index.d.mts +2 -0
- package/dist/workflows/index.mjs +6 -0
- package/package.json +39 -3
- package/dist/index-D_RBJmVt.d.mts +0 -44
package/dist/tools/index.mjs
CHANGED
|
@@ -1,4 +1,224 @@
|
|
|
1
|
-
//#region src/tools/
|
|
1
|
+
//#region src/tools/connection.ts
|
|
2
|
+
/** Safe, provider-neutral error surfaced by connection adapters. */
|
|
3
|
+
var IntegrationError = class extends Error {
|
|
4
|
+
code;
|
|
5
|
+
category;
|
|
6
|
+
retryable;
|
|
7
|
+
safeMessage;
|
|
8
|
+
name = "IntegrationError";
|
|
9
|
+
constructor(code, category, retryable, safeMessage, options) {
|
|
10
|
+
super(safeMessage, options);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.category = category;
|
|
13
|
+
this.retryable = retryable;
|
|
14
|
+
this.safeMessage = safeMessage;
|
|
15
|
+
this.source = options?.source;
|
|
16
|
+
}
|
|
17
|
+
source;
|
|
18
|
+
};
|
|
19
|
+
function defineConnection(connection) {
|
|
20
|
+
return connection;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/tools/json-schema-profile.ts
|
|
24
|
+
const FEVEX_JSON_SCHEMA_PROFILE_VERSION = "1";
|
|
25
|
+
const DEFAULT_LIMITS = {
|
|
26
|
+
maxBytes: 64e3,
|
|
27
|
+
maxDepth: 32,
|
|
28
|
+
maxNodes: 1e3,
|
|
29
|
+
maxProperties: 200
|
|
30
|
+
};
|
|
31
|
+
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
32
|
+
"$defs",
|
|
33
|
+
"$ref",
|
|
34
|
+
"additionalProperties",
|
|
35
|
+
"allOf",
|
|
36
|
+
"anyOf",
|
|
37
|
+
"const",
|
|
38
|
+
"default",
|
|
39
|
+
"description",
|
|
40
|
+
"enum",
|
|
41
|
+
"items",
|
|
42
|
+
"maxItems",
|
|
43
|
+
"maxLength",
|
|
44
|
+
"maximum",
|
|
45
|
+
"minItems",
|
|
46
|
+
"minLength",
|
|
47
|
+
"minimum",
|
|
48
|
+
"oneOf",
|
|
49
|
+
"properties",
|
|
50
|
+
"required",
|
|
51
|
+
"title",
|
|
52
|
+
"type"
|
|
53
|
+
]);
|
|
54
|
+
const DEFERRED = /* @__PURE__ */ new Set([
|
|
55
|
+
"dependentSchemas",
|
|
56
|
+
"format",
|
|
57
|
+
"if",
|
|
58
|
+
"not",
|
|
59
|
+
"pattern",
|
|
60
|
+
"then",
|
|
61
|
+
"else",
|
|
62
|
+
"unevaluatedProperties"
|
|
63
|
+
]);
|
|
64
|
+
function validateFevexJsonSchemaProfile(schema, options = {}) {
|
|
65
|
+
const limits = {
|
|
66
|
+
...DEFAULT_LIMITS,
|
|
67
|
+
...options.limits
|
|
68
|
+
};
|
|
69
|
+
if (JSON.stringify(schema).length > limits.maxBytes) throw new TypeError(`JSON Schema exceeds maxBytes limit of ${limits.maxBytes}`);
|
|
70
|
+
visitSchema(schema, options.rootDocument ?? schema, options.requireRootObject ?? false, limits, { nodes: 0 }, [], 0);
|
|
71
|
+
return schema;
|
|
72
|
+
}
|
|
73
|
+
function compileFevexJsonSchema(schema, options = {}) {
|
|
74
|
+
validateFevexJsonSchemaProfile(schema, options);
|
|
75
|
+
const rootDocument = options.rootDocument ?? schema;
|
|
76
|
+
return {
|
|
77
|
+
schema,
|
|
78
|
+
validate(value, path = "$") {
|
|
79
|
+
validateValue(schema, rootDocument, value, path, []);
|
|
80
|
+
return toJsonValue(value, `${path} must be JSON-serializable`);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function visitSchema(schema, rootDocument, requireRootObject, limits, stats, refs, depth) {
|
|
85
|
+
stats.nodes += 1;
|
|
86
|
+
if (stats.nodes > limits.maxNodes) throw new TypeError(`JSON Schema exceeds maxNodes limit of ${limits.maxNodes}`);
|
|
87
|
+
if (depth > limits.maxDepth) throw new TypeError(`JSON Schema exceeds maxDepth limit of ${limits.maxDepth}`);
|
|
88
|
+
for (const key of Object.keys(schema)) if (DEFERRED.has(key) || !KEYWORDS.has(key)) throw new TypeError(`JSON Schema keyword "${key}" is not supported`);
|
|
89
|
+
if (requireRootObject && schema.type !== "object" && !schema.$ref && !schema.allOf) throw new TypeError("Tool input JSON Schema root must be object");
|
|
90
|
+
if (typeof schema.$ref === "string") {
|
|
91
|
+
const ref = schema.$ref;
|
|
92
|
+
if (!ref.startsWith("#/")) throw new TypeError(`Remote JSON Schema ref "${ref}" is not supported`);
|
|
93
|
+
if (refs.includes(ref)) throw new TypeError(`JSON Schema ref cycle detected at "${ref}"`);
|
|
94
|
+
visitSchema(resolveRef(rootDocument, ref), rootDocument, false, limits, stats, [...refs, ref], depth + 1);
|
|
95
|
+
}
|
|
96
|
+
if (schema.properties !== void 0) {
|
|
97
|
+
if (!isRecord(schema.properties)) throw new TypeError("JSON Schema properties must be an object");
|
|
98
|
+
const entries = Object.entries(schema.properties);
|
|
99
|
+
if (entries.length > limits.maxProperties) throw new TypeError(`JSON Schema exceeds maxProperties limit of ${limits.maxProperties}`);
|
|
100
|
+
for (const [, child] of entries) {
|
|
101
|
+
if (!isRecord(child)) throw new TypeError("JSON Schema property schemas must be objects");
|
|
102
|
+
visitSchema(child, rootDocument, false, limits, stats, refs, depth + 1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const key of ["$defs"]) {
|
|
106
|
+
if (schema[key] === void 0) continue;
|
|
107
|
+
if (!isRecord(schema[key])) throw new TypeError(`JSON Schema ${key} must be an object`);
|
|
108
|
+
for (const child of Object.values(schema[key])) {
|
|
109
|
+
if (!isRecord(child)) throw new TypeError(`JSON Schema ${key} entries must be objects`);
|
|
110
|
+
visitSchema(child, rootDocument, false, limits, stats, refs, depth + 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (schema.items !== void 0) {
|
|
114
|
+
if (!isRecord(schema.items)) throw new TypeError("JSON Schema items must be an object");
|
|
115
|
+
visitSchema(schema.items, rootDocument, false, limits, stats, refs, depth + 1);
|
|
116
|
+
}
|
|
117
|
+
for (const key of [
|
|
118
|
+
"allOf",
|
|
119
|
+
"anyOf",
|
|
120
|
+
"oneOf"
|
|
121
|
+
]) {
|
|
122
|
+
if (schema[key] === void 0) continue;
|
|
123
|
+
if (!Array.isArray(schema[key])) throw new TypeError(`JSON Schema ${key} must be an array`);
|
|
124
|
+
for (const child of schema[key]) {
|
|
125
|
+
if (!isRecord(child)) throw new TypeError(`JSON Schema ${key} entries must be objects`);
|
|
126
|
+
visitSchema(child, rootDocument, false, limits, stats, refs, depth + 1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (schema.additionalProperties !== void 0 && schema.additionalProperties !== false) {
|
|
130
|
+
if (schema.additionalProperties !== true && !isRecord(schema.additionalProperties)) throw new TypeError("JSON Schema additionalProperties must be boolean or object");
|
|
131
|
+
if (isRecord(schema.additionalProperties)) visitSchema(schema.additionalProperties, rootDocument, false, limits, stats, refs, depth + 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function validateValue(schema, rootDocument, value, path, refs) {
|
|
135
|
+
if (typeof schema.$ref === "string") {
|
|
136
|
+
if (refs.includes(schema.$ref)) throw new TypeError(`JSON Schema ref cycle detected at "${schema.$ref}"`);
|
|
137
|
+
return validateValue(resolveRef(rootDocument, schema.$ref), rootDocument, value, path, [...refs, schema.$ref]);
|
|
138
|
+
}
|
|
139
|
+
if (Array.isArray(schema.allOf)) for (const child of schema.allOf) validateValue(child, rootDocument, value, path, refs);
|
|
140
|
+
if (Array.isArray(schema.anyOf)) {
|
|
141
|
+
if (!schema.anyOf.some((child) => passes(child, rootDocument, value, path, refs))) throw new TypeError(`${path} must match anyOf`);
|
|
142
|
+
}
|
|
143
|
+
if (Array.isArray(schema.oneOf)) {
|
|
144
|
+
if (schema.oneOf.filter((child) => passes(child, rootDocument, value, path, refs)).length !== 1) throw new TypeError(`${path} must match exactly one oneOf schema`);
|
|
145
|
+
}
|
|
146
|
+
if ("const" in schema && JSON.stringify(value) !== JSON.stringify(schema.const)) throw new TypeError(`${path} must equal const`);
|
|
147
|
+
if (Array.isArray(schema.enum) && !schema.enum.some((item) => JSON.stringify(item) === JSON.stringify(value))) throw new TypeError(`${path} must be one of enum`);
|
|
148
|
+
validateType(schema.type, value, path);
|
|
149
|
+
if (schema.type === "object" || isRecord(value)) validateObject(schema, rootDocument, value, path, refs);
|
|
150
|
+
if (schema.type === "array" || Array.isArray(value)) validateArray(schema, rootDocument, value, path, refs);
|
|
151
|
+
if (typeof value === "string") {
|
|
152
|
+
if (typeof schema.minLength === "number" && value.length < schema.minLength) throw new TypeError(`${path} is shorter than minLength`);
|
|
153
|
+
if (typeof schema.maxLength === "number" && value.length > schema.maxLength) throw new TypeError(`${path} is longer than maxLength`);
|
|
154
|
+
}
|
|
155
|
+
if (typeof value === "number") {
|
|
156
|
+
if (typeof schema.minimum === "number" && value < schema.minimum) throw new TypeError(`${path} is below minimum`);
|
|
157
|
+
if (typeof schema.maximum === "number" && value > schema.maximum) throw new TypeError(`${path} is above maximum`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function validateObject(schema, rootDocument, value, path, refs) {
|
|
161
|
+
if (!isRecord(value)) return;
|
|
162
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
163
|
+
for (const key of required) if (typeof key === "string" && !(key in value)) throw new TypeError(`${path}.${key} is required`);
|
|
164
|
+
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
165
|
+
for (const [key, child] of Object.entries(properties)) if (key in value && isRecord(child)) validateValue(child, rootDocument, value[key], `${path}.${key}`, refs);
|
|
166
|
+
if (schema.additionalProperties === false) {
|
|
167
|
+
for (const key of Object.keys(value)) if (!(key in properties)) throw new TypeError(`${path}.${key} is not allowed`);
|
|
168
|
+
} else if (isRecord(schema.additionalProperties)) {
|
|
169
|
+
for (const [key, item] of Object.entries(value)) if (!(key in properties)) validateValue(schema.additionalProperties, rootDocument, item, `${path}.${key}`, refs);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function validateArray(schema, rootDocument, value, path, refs) {
|
|
173
|
+
if (!Array.isArray(value)) return;
|
|
174
|
+
if (typeof schema.minItems === "number" && value.length < schema.minItems) throw new TypeError(`${path} has fewer than minItems`);
|
|
175
|
+
if (typeof schema.maxItems === "number" && value.length > schema.maxItems) throw new TypeError(`${path} has more than maxItems`);
|
|
176
|
+
if (isRecord(schema.items)) value.forEach((item, index) => validateValue(schema.items, rootDocument, item, `${path}[${index}]`, refs));
|
|
177
|
+
}
|
|
178
|
+
function validateType(type, value, path) {
|
|
179
|
+
if (type === void 0) return;
|
|
180
|
+
const types = Array.isArray(type) ? type : [type];
|
|
181
|
+
if (!types.some((item) => {
|
|
182
|
+
if (item === "array") return Array.isArray(value);
|
|
183
|
+
if (item === "integer") return Number.isInteger(value);
|
|
184
|
+
if (item === "number") return typeof value === "number" && Number.isFinite(value);
|
|
185
|
+
if (item === "object") return isRecord(value);
|
|
186
|
+
if (item === "null") return value === null;
|
|
187
|
+
return typeof value === item;
|
|
188
|
+
})) throw new TypeError(`${path} must be ${types.join(" or ")}`);
|
|
189
|
+
}
|
|
190
|
+
function passes(schema, rootDocument, value, path, refs) {
|
|
191
|
+
try {
|
|
192
|
+
validateValue(schema, rootDocument, value, path, refs);
|
|
193
|
+
return true;
|
|
194
|
+
} catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function resolveRef(rootDocument, ref) {
|
|
199
|
+
const segments = ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
200
|
+
let current = rootDocument;
|
|
201
|
+
for (const segment of segments) {
|
|
202
|
+
if (!isRecord(current) || !(segment in current)) throw new TypeError(`JSON Schema ref "${ref}" cannot be resolved`);
|
|
203
|
+
current = current[segment];
|
|
204
|
+
}
|
|
205
|
+
if (!isRecord(current)) throw new TypeError(`JSON Schema ref "${ref}" must resolve to an object`);
|
|
206
|
+
return current;
|
|
207
|
+
}
|
|
208
|
+
function toJsonValue(value, message) {
|
|
209
|
+
try {
|
|
210
|
+
const cloned = JSON.parse(JSON.stringify(value));
|
|
211
|
+
if (cloned === void 0) throw new TypeError(message);
|
|
212
|
+
return cloned;
|
|
213
|
+
} catch {
|
|
214
|
+
throw new TypeError(message);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function isRecord(value) {
|
|
218
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/tools/tool.ts
|
|
2
222
|
function defineTool(tool) {
|
|
3
223
|
return tool;
|
|
4
224
|
}
|
|
@@ -10,4 +230,4 @@ function toToolSpec(tool, inputSchema) {
|
|
|
10
230
|
};
|
|
11
231
|
}
|
|
12
232
|
//#endregion
|
|
13
|
-
export { defineTool, toToolSpec };
|
|
233
|
+
export { FEVEX_JSON_SCHEMA_PROFILE_VERSION, IntegrationError, compileFevexJsonSchema, defineConnection, defineTool, toToolSpec, validateFevexJsonSchemaProfile };
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
/** A value that can cross provider and persistence boundaries without conversion. */
|
|
3
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
4
|
+
type JsonObject = {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
8
|
+
type RunId = string;
|
|
9
|
+
declare const SCHEMA_NOT_TRANSPORTABLE = "SCHEMA_NOT_TRANSPORTABLE";
|
|
10
|
+
declare const PROVIDER_SCHEMA_UNSUPPORTED = "PROVIDER_SCHEMA_UNSUPPORTED";
|
|
11
|
+
declare const PROVIDER_REASONING_UNSUPPORTED = "PROVIDER_REASONING_UNSUPPORTED";
|
|
12
|
+
interface ExecutionContext {
|
|
13
|
+
namespace?: string;
|
|
14
|
+
actor?: {
|
|
15
|
+
id: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
};
|
|
18
|
+
attributes?: JsonObject;
|
|
19
|
+
prompt?: JsonObject;
|
|
20
|
+
}
|
|
21
|
+
type AgentMessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
22
|
+
interface AgentMessage {
|
|
23
|
+
role: AgentMessageRole;
|
|
24
|
+
content: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
toolCallId?: string;
|
|
27
|
+
toolCalls?: ToolCall[];
|
|
28
|
+
}
|
|
29
|
+
interface ToolSpec {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
inputSchema?: JsonObject;
|
|
33
|
+
}
|
|
34
|
+
interface ToolCall {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
input: JsonValue;
|
|
38
|
+
}
|
|
39
|
+
interface ToolEventSource {
|
|
40
|
+
kind: 'connection';
|
|
41
|
+
provider: string;
|
|
42
|
+
connectionName: string;
|
|
43
|
+
remoteToolName: string;
|
|
44
|
+
}
|
|
45
|
+
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' | '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';
|
|
46
|
+
interface AgentEventPayloads {
|
|
47
|
+
'run.started': undefined;
|
|
48
|
+
'run.recovered': {
|
|
49
|
+
actorId: string;
|
|
50
|
+
};
|
|
51
|
+
'run.paused': {
|
|
52
|
+
reason: 'elicitation' | 'approval' | 'tool_execution_unknown';
|
|
53
|
+
toolCallId: string;
|
|
54
|
+
};
|
|
55
|
+
'run.resumed': undefined;
|
|
56
|
+
'model.started': {
|
|
57
|
+
step: number;
|
|
58
|
+
workflowStepId?: string;
|
|
59
|
+
workflowAgentName?: string;
|
|
60
|
+
teamDelegationId?: string;
|
|
61
|
+
teamAgentName?: string;
|
|
62
|
+
};
|
|
63
|
+
'model.output.delta': {
|
|
64
|
+
step: number;
|
|
65
|
+
delta: string;
|
|
66
|
+
workflowStepId?: string;
|
|
67
|
+
workflowAgentName?: string;
|
|
68
|
+
teamDelegationId?: string;
|
|
69
|
+
teamAgentName?: string;
|
|
70
|
+
};
|
|
71
|
+
'model.completed': {
|
|
72
|
+
step: number;
|
|
73
|
+
usage?: JsonObject;
|
|
74
|
+
workflowStepId?: string;
|
|
75
|
+
workflowAgentName?: string;
|
|
76
|
+
teamDelegationId?: string;
|
|
77
|
+
teamAgentName?: string;
|
|
78
|
+
};
|
|
79
|
+
'tool.started': {
|
|
80
|
+
step: number;
|
|
81
|
+
toolCallId: string;
|
|
82
|
+
toolName: string;
|
|
83
|
+
attempt?: number;
|
|
84
|
+
source?: ToolEventSource;
|
|
85
|
+
workflowStepId?: string;
|
|
86
|
+
workflowAgentName?: string;
|
|
87
|
+
teamDelegationId?: string;
|
|
88
|
+
teamAgentName?: string;
|
|
89
|
+
};
|
|
90
|
+
'tool.completed': {
|
|
91
|
+
step: number;
|
|
92
|
+
toolCallId: string;
|
|
93
|
+
toolName: string;
|
|
94
|
+
attempt?: number;
|
|
95
|
+
source?: ToolEventSource;
|
|
96
|
+
workflowStepId?: string;
|
|
97
|
+
workflowAgentName?: string;
|
|
98
|
+
teamDelegationId?: string;
|
|
99
|
+
teamAgentName?: string;
|
|
100
|
+
};
|
|
101
|
+
'tool.failed': {
|
|
102
|
+
step: number;
|
|
103
|
+
toolCallId: string;
|
|
104
|
+
toolName: string;
|
|
105
|
+
error: string;
|
|
106
|
+
errorCode?: string;
|
|
107
|
+
retryable?: boolean;
|
|
108
|
+
source?: ToolEventSource;
|
|
109
|
+
workflowStepId?: string;
|
|
110
|
+
workflowAgentName?: string;
|
|
111
|
+
teamDelegationId?: string;
|
|
112
|
+
teamAgentName?: string;
|
|
113
|
+
};
|
|
114
|
+
'tool.retrying': {
|
|
115
|
+
step: number;
|
|
116
|
+
toolCallId: string;
|
|
117
|
+
toolName: string;
|
|
118
|
+
attempt: number;
|
|
119
|
+
delayMs: number;
|
|
120
|
+
error: string;
|
|
121
|
+
errorCode?: string;
|
|
122
|
+
retryable?: boolean;
|
|
123
|
+
source?: ToolEventSource;
|
|
124
|
+
workflowStepId?: string;
|
|
125
|
+
workflowAgentName?: string;
|
|
126
|
+
teamDelegationId?: string;
|
|
127
|
+
teamAgentName?: string;
|
|
128
|
+
};
|
|
129
|
+
'tool.execution_unknown': {
|
|
130
|
+
step: number;
|
|
131
|
+
toolCallId: string;
|
|
132
|
+
toolName: string;
|
|
133
|
+
source?: ToolEventSource;
|
|
134
|
+
workflowStepId?: string;
|
|
135
|
+
workflowAgentName?: string;
|
|
136
|
+
teamDelegationId?: string;
|
|
137
|
+
teamAgentName?: string;
|
|
138
|
+
};
|
|
139
|
+
'elicitation.requested': {
|
|
140
|
+
request: {
|
|
141
|
+
id: string;
|
|
142
|
+
toolCallId: string;
|
|
143
|
+
prompt: string;
|
|
144
|
+
responseSchema: JsonObject;
|
|
145
|
+
requestedAt: string;
|
|
146
|
+
expiresAt?: string;
|
|
147
|
+
};
|
|
148
|
+
workflowStepId?: string;
|
|
149
|
+
workflowAgentName?: string;
|
|
150
|
+
teamDelegationId?: string;
|
|
151
|
+
teamAgentName?: string;
|
|
152
|
+
};
|
|
153
|
+
'elicitation.resolved': {
|
|
154
|
+
requestId: string;
|
|
155
|
+
toolCallId: string;
|
|
156
|
+
actorId: string;
|
|
157
|
+
workflowStepId?: string;
|
|
158
|
+
workflowAgentName?: string;
|
|
159
|
+
teamDelegationId?: string;
|
|
160
|
+
teamAgentName?: string;
|
|
161
|
+
};
|
|
162
|
+
'approval.requested': {
|
|
163
|
+
approvalId: string;
|
|
164
|
+
toolCallId: string;
|
|
165
|
+
toolName: string;
|
|
166
|
+
toolLabel?: string;
|
|
167
|
+
source?: ToolEventSource;
|
|
168
|
+
workflowStepId?: string;
|
|
169
|
+
workflowAgentName?: string;
|
|
170
|
+
teamDelegationId?: string;
|
|
171
|
+
teamAgentName?: string;
|
|
172
|
+
};
|
|
173
|
+
'approval.resolved': {
|
|
174
|
+
approvalId: string;
|
|
175
|
+
toolCallId: string;
|
|
176
|
+
decision: 'approve' | 'reject';
|
|
177
|
+
actorId: string;
|
|
178
|
+
toolLabel?: string;
|
|
179
|
+
source?: ToolEventSource;
|
|
180
|
+
workflowStepId?: string;
|
|
181
|
+
workflowAgentName?: string;
|
|
182
|
+
teamDelegationId?: string;
|
|
183
|
+
teamAgentName?: string;
|
|
184
|
+
};
|
|
185
|
+
'run.completed': {
|
|
186
|
+
output: JsonValue;
|
|
187
|
+
usage?: JsonObject;
|
|
188
|
+
};
|
|
189
|
+
'run.failed': {
|
|
190
|
+
error: string;
|
|
191
|
+
errorCode?: string;
|
|
192
|
+
retryable?: boolean;
|
|
193
|
+
source?: ToolEventSource;
|
|
194
|
+
};
|
|
195
|
+
'run.cancelled': {
|
|
196
|
+
reason: 'aborted' | 'timeout' | 'approval_rejected';
|
|
197
|
+
};
|
|
198
|
+
'workflow.run.started': undefined;
|
|
199
|
+
'workflow.run.recovered': {
|
|
200
|
+
actorId: string;
|
|
201
|
+
};
|
|
202
|
+
'workflow.step.started': {
|
|
203
|
+
stepId: string;
|
|
204
|
+
kind: 'agent' | 'parallel';
|
|
205
|
+
agentName?: string;
|
|
206
|
+
};
|
|
207
|
+
'workflow.step.completed': {
|
|
208
|
+
stepId: string;
|
|
209
|
+
kind: 'agent' | 'parallel';
|
|
210
|
+
};
|
|
211
|
+
'workflow.step.failed': {
|
|
212
|
+
stepId: string;
|
|
213
|
+
kind: 'agent' | 'parallel';
|
|
214
|
+
error: string;
|
|
215
|
+
};
|
|
216
|
+
'workflow.compensation.started': {
|
|
217
|
+
stepId: string;
|
|
218
|
+
kind: 'agent' | 'parallel';
|
|
219
|
+
};
|
|
220
|
+
'workflow.compensation.completed': {
|
|
221
|
+
stepId: string;
|
|
222
|
+
kind: 'agent' | 'parallel';
|
|
223
|
+
};
|
|
224
|
+
'workflow.compensation.failed': {
|
|
225
|
+
stepId: string;
|
|
226
|
+
kind: 'agent' | 'parallel';
|
|
227
|
+
error: string;
|
|
228
|
+
};
|
|
229
|
+
'workflow.wait.started': {
|
|
230
|
+
stepId: string;
|
|
231
|
+
kind: 'timer' | 'event';
|
|
232
|
+
resumeAt?: string;
|
|
233
|
+
eventName?: string;
|
|
234
|
+
};
|
|
235
|
+
'workflow.wait.completed': {
|
|
236
|
+
stepId: string;
|
|
237
|
+
kind: 'timer' | 'event';
|
|
238
|
+
payload?: JsonValue;
|
|
239
|
+
actorId?: string;
|
|
240
|
+
receivedAt?: string;
|
|
241
|
+
};
|
|
242
|
+
'workflow.run.paused': {
|
|
243
|
+
stepId: string;
|
|
244
|
+
reason: 'child' | 'timer' | 'event';
|
|
245
|
+
childRunId?: string;
|
|
246
|
+
};
|
|
247
|
+
'workflow.run.resumed': undefined;
|
|
248
|
+
'workflow.run.completed': {
|
|
249
|
+
output: JsonValue;
|
|
250
|
+
usage?: JsonObject;
|
|
251
|
+
};
|
|
252
|
+
'workflow.run.failed': {
|
|
253
|
+
error: string;
|
|
254
|
+
errorCode?: string;
|
|
255
|
+
retryable?: boolean;
|
|
256
|
+
source?: ToolEventSource;
|
|
257
|
+
};
|
|
258
|
+
'workflow.run.cancelled': {
|
|
259
|
+
reason: 'aborted' | 'timeout' | 'approval_rejected';
|
|
260
|
+
};
|
|
261
|
+
'team.run.started': undefined;
|
|
262
|
+
'team.run.recovered': {
|
|
263
|
+
actorId: string;
|
|
264
|
+
};
|
|
265
|
+
'team.agent.assigned': {
|
|
266
|
+
delegationId: string;
|
|
267
|
+
agentName: string;
|
|
268
|
+
action: 'delegate' | 'handoff';
|
|
269
|
+
expectedOutput?: string;
|
|
270
|
+
constraints?: string[];
|
|
271
|
+
};
|
|
272
|
+
'team.handoff.created': {
|
|
273
|
+
delegationId: string;
|
|
274
|
+
from: string;
|
|
275
|
+
to: string;
|
|
276
|
+
reason: string;
|
|
277
|
+
};
|
|
278
|
+
'team.task.completed': {
|
|
279
|
+
delegationId: string;
|
|
280
|
+
agentName: string;
|
|
281
|
+
usage?: JsonObject;
|
|
282
|
+
};
|
|
283
|
+
'team.task.failed': {
|
|
284
|
+
delegationId: string;
|
|
285
|
+
agentName?: string;
|
|
286
|
+
error: string;
|
|
287
|
+
};
|
|
288
|
+
'team.merge.started': {
|
|
289
|
+
stepId: string;
|
|
290
|
+
width: number;
|
|
291
|
+
};
|
|
292
|
+
'team.merge.completed': {
|
|
293
|
+
stepId: string;
|
|
294
|
+
};
|
|
295
|
+
'team.merge.failed': {
|
|
296
|
+
stepId: string;
|
|
297
|
+
error: string;
|
|
298
|
+
};
|
|
299
|
+
'team.run.paused': {
|
|
300
|
+
delegationId: string;
|
|
301
|
+
reason: 'child' | 'timer' | 'event';
|
|
302
|
+
childRunId?: string;
|
|
303
|
+
};
|
|
304
|
+
'team.run.resumed': undefined;
|
|
305
|
+
'team.run.completed': {
|
|
306
|
+
output: JsonValue;
|
|
307
|
+
usage?: JsonObject;
|
|
308
|
+
};
|
|
309
|
+
'team.run.failed': {
|
|
310
|
+
error: string;
|
|
311
|
+
errorCode?: string;
|
|
312
|
+
retryable?: boolean;
|
|
313
|
+
source?: ToolEventSource;
|
|
314
|
+
};
|
|
315
|
+
'team.run.cancelled': {
|
|
316
|
+
reason: 'aborted' | 'timeout' | 'approval_rejected';
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
interface AgentEventBase {
|
|
320
|
+
id: string;
|
|
321
|
+
sequence: number;
|
|
322
|
+
runId: RunId;
|
|
323
|
+
timestamp: string;
|
|
324
|
+
}
|
|
325
|
+
type AgentEvent<TType extends AgentEventType = AgentEventType> = { [TCurrent in TType]: AgentEventBase & {
|
|
326
|
+
type: TCurrent;
|
|
327
|
+
} & (AgentEventPayloads[TCurrent] extends undefined ? {
|
|
328
|
+
payload?: never;
|
|
329
|
+
} : {
|
|
330
|
+
payload: AgentEventPayloads[TCurrent];
|
|
331
|
+
}); }[TType];
|
|
332
|
+
//#endregion
|
|
333
|
+
export { AgentMessageRole as a, JsonPrimitive as c, PROVIDER_SCHEMA_UNSUPPORTED as d, RunId as f, ToolSpec as g, ToolEventSource as h, AgentMessage as i, 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 };
|
|
@@ -0,0 +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";
|
|
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.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Agent Engineering Framework for code-first, provider-neutral AI agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,6 +31,18 @@
|
|
|
31
31
|
"types": "./dist/agents/index.d.mts",
|
|
32
32
|
"import": "./dist/agents/index.mjs"
|
|
33
33
|
},
|
|
34
|
+
"./channels": {
|
|
35
|
+
"types": "./dist/channels/index.d.mts",
|
|
36
|
+
"import": "./dist/channels/index.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./http": {
|
|
39
|
+
"types": "./dist/http/index.d.mts",
|
|
40
|
+
"import": "./dist/http/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./knowledge": {
|
|
43
|
+
"types": "./dist/knowledge/index.d.mts",
|
|
44
|
+
"import": "./dist/knowledge/index.mjs"
|
|
45
|
+
},
|
|
34
46
|
"./models": {
|
|
35
47
|
"types": "./dist/models/index.d.mts",
|
|
36
48
|
"import": "./dist/models/index.mjs"
|
|
@@ -39,19 +51,43 @@
|
|
|
39
51
|
"types": "./dist/tools/index.d.mts",
|
|
40
52
|
"import": "./dist/tools/index.mjs"
|
|
41
53
|
},
|
|
54
|
+
"./workflows": {
|
|
55
|
+
"types": "./dist/workflows/index.d.mts",
|
|
56
|
+
"import": "./dist/workflows/index.mjs"
|
|
57
|
+
},
|
|
58
|
+
"./teams": {
|
|
59
|
+
"types": "./dist/teams/index.d.mts",
|
|
60
|
+
"import": "./dist/teams/index.mjs"
|
|
61
|
+
},
|
|
42
62
|
"./runtime": {
|
|
43
63
|
"types": "./dist/runtime/index.d.mts",
|
|
44
64
|
"import": "./dist/runtime/index.mjs"
|
|
45
65
|
},
|
|
66
|
+
"./sandbox": {
|
|
67
|
+
"types": "./dist/sandbox/index.d.mts",
|
|
68
|
+
"import": "./dist/sandbox/index.mjs"
|
|
69
|
+
},
|
|
70
|
+
"./policies": {
|
|
71
|
+
"types": "./dist/policies/index.d.mts",
|
|
72
|
+
"import": "./dist/policies/index.mjs"
|
|
73
|
+
},
|
|
74
|
+
"./observability": {
|
|
75
|
+
"types": "./dist/observability/index.d.mts",
|
|
76
|
+
"import": "./dist/observability/index.mjs"
|
|
77
|
+
},
|
|
78
|
+
"./evals": {
|
|
79
|
+
"types": "./dist/evals/index.d.mts",
|
|
80
|
+
"import": "./dist/evals/index.mjs"
|
|
81
|
+
},
|
|
46
82
|
"./testing": {
|
|
47
83
|
"types": "./dist/testing/index.d.mts",
|
|
48
84
|
"import": "./dist/testing/index.mjs"
|
|
49
85
|
}
|
|
50
86
|
},
|
|
51
87
|
"scripts": {
|
|
52
|
-
"build": "tsdown src/index.ts src/agents/index.ts src/models/index.ts src/tools/index.ts src/runtime/index.ts src/testing/index.ts --format esm --dts",
|
|
88
|
+
"build": "tsdown src/index.ts src/agents/index.ts src/channels/index.ts src/http/index.ts src/knowledge/index.ts src/models/index.ts src/tools/index.ts src/workflows/index.ts src/teams/index.ts src/runtime/index.ts src/sandbox/index.ts src/policies/index.ts src/observability/index.ts src/evals/index.ts src/testing/index.ts --format esm --dts --clean",
|
|
53
89
|
"prepack": "bun run build",
|
|
54
|
-
"test": "bun test
|
|
90
|
+
"test": "bun test --cwd src",
|
|
55
91
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
56
92
|
},
|
|
57
93
|
"publishConfig": {
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//#region src/core/index.d.ts
|
|
2
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
3
|
-
type JsonObject = {
|
|
4
|
-
[key: string]: JsonValue;
|
|
5
|
-
};
|
|
6
|
-
type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
7
|
-
type RunId = string;
|
|
8
|
-
declare const SCHEMA_NOT_TRANSPORTABLE = "SCHEMA_NOT_TRANSPORTABLE";
|
|
9
|
-
interface ExecutionContext {
|
|
10
|
-
namespace?: string;
|
|
11
|
-
actor?: {
|
|
12
|
-
id: string;
|
|
13
|
-
type?: string;
|
|
14
|
-
};
|
|
15
|
-
attributes?: JsonObject;
|
|
16
|
-
prompt?: JsonObject;
|
|
17
|
-
}
|
|
18
|
-
type AgentMessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
19
|
-
interface AgentMessage {
|
|
20
|
-
role: AgentMessageRole;
|
|
21
|
-
content: string;
|
|
22
|
-
name?: string;
|
|
23
|
-
toolCallId?: string;
|
|
24
|
-
toolCalls?: ToolCall[];
|
|
25
|
-
}
|
|
26
|
-
interface ToolSpec {
|
|
27
|
-
name: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
inputSchema?: JsonObject;
|
|
30
|
-
}
|
|
31
|
-
interface ToolCall {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
input: JsonValue;
|
|
35
|
-
}
|
|
36
|
-
type AgentEventType = 'run.started' | 'model.completed' | 'tool.completed' | 'tool.failed' | 'run.completed' | 'run.failed';
|
|
37
|
-
interface AgentEvent<TPayload extends JsonValue = JsonObject> {
|
|
38
|
-
type: AgentEventType;
|
|
39
|
-
runId: RunId;
|
|
40
|
-
timestamp: string;
|
|
41
|
-
payload?: TPayload;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { ExecutionContext as a, JsonValue as c, ToolCall as d, ToolSpec as f, AgentMessageRole as i, RunId as l, AgentEventType as n, JsonObject as o, AgentMessage as r, JsonPrimitive as s, AgentEvent as t, SCHEMA_NOT_TRANSPORTABLE as u };
|