@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,224 @@
1
+ import { u as EmbeddingModel } from "./index-D7r0puBi.mjs";
2
+ import { F as ArtifactStore, f as RunId, g as ToolSpec, h as ToolEventSource, l as JsonValue, o as ExecutionContext, s as JsonObject } from "./types-CckDlhYo.mjs";
3
+ import { i as SandboxCapabilities, r as Sandbox } from "./index-DUhNa7IR.mjs";
4
+ import { StandardSchemaV1 } from "@standard-schema/spec";
5
+ //#region src/internal/exact-definition.d.ts
6
+ type ExactDefinition<TInput, TShape> = TInput & { readonly [TKey in Exclude<keyof TInput, keyof TShape>]: never; };
7
+ //#endregion
8
+ //#region src/tools/tool.d.ts
9
+ interface ToolExecutionContext {
10
+ runId: RunId;
11
+ toolCallId: string;
12
+ attempt: number;
13
+ idempotencyKey: string;
14
+ getCredential(name: string): Promise<string>;
15
+ sandbox?: Sandbox;
16
+ /** Optional artifact store; writes emit `artifact.created`. */
17
+ artifacts?: ArtifactStore;
18
+ context?: ExecutionContext;
19
+ signal?: AbortSignal;
20
+ }
21
+ type ToolRisk = 'read' | 'write' | 'sensitive' | 'destructive';
22
+ type ToolApproval = 'never' | 'required';
23
+ type ToolIdempotency = 'none' | 'keyed';
24
+ interface ToolRetryPolicy {
25
+ maxAttempts: number;
26
+ backoffMs: number;
27
+ maxBackoffMs?: number;
28
+ }
29
+ interface ToolDefinition<TInput = unknown, TOutput = unknown> {
30
+ name: string;
31
+ label?: string;
32
+ description?: string;
33
+ inputSchema?: StandardSchemaV1<unknown, TInput>;
34
+ outputSchema?: StandardSchemaV1<unknown, TOutput>;
35
+ inputJsonSchema?: JsonObject;
36
+ outputJsonSchema?: JsonObject;
37
+ risk?: ToolRisk;
38
+ approval?: ToolApproval;
39
+ idempotency?: ToolIdempotency;
40
+ retry?: ToolRetryPolicy;
41
+ credentials?: string[];
42
+ sandbox?: SandboxCapabilities;
43
+ /** Maximum serialized bytes for one result. Use an artifact or `false` to opt out of the default cap. */
44
+ maxResultBytes?: number | false;
45
+ source?: ToolEventSource;
46
+ resolve?: (context?: ToolProviderContext) => Promise<ToolProviderTool | undefined>;
47
+ execute(input: TInput, context: ToolExecutionContext): TOutput | Promise<TOutput>;
48
+ }
49
+ type ToolWithSchemas<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1> = Omit<ToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, StandardSchemaV1.InferOutput<TOutputSchema>>, 'inputSchema' | 'outputSchema'> & {
50
+ inputSchema: TInputSchema;
51
+ outputSchema: TOutputSchema;
52
+ };
53
+ type ToolWithInputSchema<TInputSchema extends StandardSchemaV1> = Omit<ToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, unknown>, 'inputSchema'> & {
54
+ inputSchema: TInputSchema;
55
+ };
56
+ declare function defineTool<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TDefinition extends ToolWithSchemas<TInputSchema, TOutputSchema>>(tool: ToolWithSchemas<TInputSchema, TOutputSchema> & ExactDefinition<TDefinition, ToolWithSchemas<TInputSchema, TOutputSchema>>): TDefinition;
57
+ declare function defineTool<TInputSchema extends StandardSchemaV1, TDefinition extends ToolWithInputSchema<TInputSchema>>(tool: ToolWithInputSchema<TInputSchema> & ExactDefinition<TDefinition, ToolWithInputSchema<TInputSchema>>): TDefinition;
58
+ declare function defineTool<TDefinition extends ToolDefinition>(tool: ToolDefinition & ExactDefinition<TDefinition, ToolDefinition>): TDefinition;
59
+ declare function toToolSpec(tool: ToolDefinition, inputSchema?: JsonObject): ToolSpec;
60
+ type ToolResult = JsonValue;
61
+ //#endregion
62
+ //#region src/tools/connection.d.ts
63
+ interface ToolProviderContext {
64
+ runId?: RunId;
65
+ toolCallId?: string;
66
+ attempt?: number;
67
+ idempotencyKey?: string;
68
+ context?: ExecutionContext;
69
+ signal?: AbortSignal;
70
+ }
71
+ interface ToolProviderTool {
72
+ name: string;
73
+ label?: string;
74
+ description?: string;
75
+ inputSchema?: JsonObject;
76
+ outputSchema?: JsonObject;
77
+ }
78
+ interface ToolProvider {
79
+ kind?: string;
80
+ listTools(context?: ToolProviderContext): Promise<ToolProviderTool[]>;
81
+ callTool(name: string, input: JsonValue, context: ToolProviderContext): JsonValue | Promise<JsonValue>;
82
+ close?(): Promise<void>;
83
+ }
84
+ type IntegrationErrorCategory = 'auth' | 'validation' | 'network' | 'remote' | 'timeout';
85
+ /** Safe, provider-neutral error surfaced by connection adapters. */
86
+ declare class IntegrationError extends Error {
87
+ readonly code: string;
88
+ readonly category: IntegrationErrorCategory;
89
+ readonly retryable: boolean;
90
+ readonly safeMessage: string;
91
+ readonly name = "IntegrationError";
92
+ constructor(code: string, category: IntegrationErrorCategory, retryable: boolean, safeMessage: string, options?: ErrorOptions & {
93
+ source?: ToolEventSource;
94
+ });
95
+ readonly source?: ToolEventSource;
96
+ }
97
+ interface ConnectionToolPolicy {
98
+ label?: string;
99
+ description?: string;
100
+ inputSchema?: JsonObject;
101
+ outputSchema?: JsonObject;
102
+ risk?: ToolRisk;
103
+ approval?: ToolApproval;
104
+ idempotency?: ToolIdempotency;
105
+ retry?: ToolRetryPolicy;
106
+ credentials?: string[];
107
+ maxResultBytes?: number | false;
108
+ }
109
+ interface ConnectionDefinition {
110
+ name: string;
111
+ provider: ToolProvider;
112
+ allowlist?: readonly string[];
113
+ tools?: {
114
+ allow: readonly string[];
115
+ } | Record<string, ConnectionToolPolicy>;
116
+ timeoutMs?: number;
117
+ }
118
+ declare function defineConnection<TDefinition extends ConnectionDefinition>(connection: TDefinition): TDefinition;
119
+ //#endregion
120
+ //#region src/tools/json-schema-profile.d.ts
121
+ declare const FEVEX_JSON_SCHEMA_PROFILE_VERSION = "1";
122
+ interface FevexJsonSchemaProfileLimits {
123
+ maxBytes?: number;
124
+ maxDepth?: number;
125
+ maxNodes?: number;
126
+ maxProperties?: number;
127
+ }
128
+ interface FevexJsonSchemaProfileOptions {
129
+ rootDocument?: JsonObject;
130
+ requireRootObject?: boolean;
131
+ limits?: FevexJsonSchemaProfileLimits;
132
+ }
133
+ interface FevexJsonSchemaValidator {
134
+ schema: JsonObject;
135
+ validate(value: unknown, path?: string): JsonValue;
136
+ }
137
+ declare function validateFevexJsonSchemaProfile(schema: JsonObject, options?: FevexJsonSchemaProfileOptions): JsonObject;
138
+ declare function compileFevexJsonSchema(schema: JsonObject, options?: FevexJsonSchemaProfileOptions): FevexJsonSchemaValidator;
139
+ //#endregion
140
+ //#region src/tools/tool-index.d.ts
141
+ /** Cache of tool embedding vectors keyed by content hash. */
142
+ interface ToolEmbeddingCache {
143
+ get(key: string): number[] | undefined | Promise<number[] | undefined>;
144
+ set(key: string, vector: number[]): void | Promise<void>;
145
+ /** Optional batch read for durable caches with network/database latency. */
146
+ getMany?(keys: readonly string[]): Array<number[] | undefined> | Promise<Array<number[] | undefined>>;
147
+ /** Optional batch write for durable caches with network/database latency. */
148
+ setMany?(entries: ReadonlyArray<{
149
+ key: string;
150
+ vector: number[];
151
+ }>): void | Promise<void>;
152
+ }
153
+ interface InMemoryToolEmbeddingCacheOptions {
154
+ /** Maximum cached vectors. Defaults to 1,000. */
155
+ maxEntries?: number;
156
+ }
157
+ /** Bounded LRU cache for tool embeddings. */
158
+ declare class InMemoryToolEmbeddingCache implements ToolEmbeddingCache {
159
+ #private;
160
+ constructor(options?: InMemoryToolEmbeddingCacheOptions);
161
+ get size(): number;
162
+ get(key: string): number[] | undefined;
163
+ set(key: string, vector: number[]): void;
164
+ getMany(keys: readonly string[]): Array<number[] | undefined>;
165
+ setMany(entries: ReadonlyArray<{
166
+ key: string;
167
+ vector: number[];
168
+ }>): void;
169
+ }
170
+ interface ToolEmbeddingIndexEntry {
171
+ tool: ToolSpec;
172
+ vector: number[];
173
+ }
174
+ interface ToolEmbeddingIndex {
175
+ modelId: string;
176
+ dimensions: number;
177
+ entries: ToolEmbeddingIndexEntry[];
178
+ }
179
+ interface BuildToolEmbeddingIndexOptions {
180
+ tools: readonly ToolSpec[];
181
+ embeddings: EmbeddingModel;
182
+ cache?: ToolEmbeddingCache;
183
+ /** Texts per embedding request. Defaults to 64. */
184
+ batchSize?: number;
185
+ signal?: AbortSignal;
186
+ }
187
+ interface ToolEmbeddingMatch {
188
+ tool: ToolSpec;
189
+ score: number;
190
+ }
191
+ /**
192
+ * Builds or refreshes a semantic index for a tool catalog. The content key is
193
+ * `sha256(embeddingModel.id + text)`, so changing the model or the tool text
194
+ * invalidates the cached vector.
195
+ */
196
+ declare function buildToolEmbeddingIndex(options: BuildToolEmbeddingIndexOptions): Promise<ToolEmbeddingIndex>;
197
+ /** Returns cosine matches above `minScore`, ordered by score. */
198
+ declare function searchToolEmbeddingIndex(index: ToolEmbeddingIndex, query: readonly number[], limit: number, minScore?: number): ToolEmbeddingMatch[];
199
+ /** Canonical text indexed for one tool: name, description and schema keywords. */
200
+ declare function toolEmbeddingText(tool: ToolSpec): string;
201
+ /** Extracts property names, descriptions, titles, required fields and enum values. */
202
+ declare function schemaKeywords(schema: JsonObject | undefined): string;
203
+ /** Stable content key for one embedding model and tool text. */
204
+ declare function toolEmbeddingKey(modelId: string, text: string): Promise<string>;
205
+ declare function cosineSimilarity(left: readonly number[], right: readonly number[]): number;
206
+ //#endregion
207
+ //#region src/tools/tool-reranker.d.ts
208
+ /** One tool candidate passed to a reranker. */
209
+ interface ToolSearchCandidate {
210
+ tool: ToolSpec;
211
+ /** Lexical/vector fusion score. Rerankers may ignore it. */
212
+ score: number;
213
+ }
214
+ /** Optional second-stage ranking over the top lexical/vector candidates. */
215
+ interface ToolReranker {
216
+ rerank(input: {
217
+ query: string;
218
+ tools: ToolSearchCandidate[];
219
+ limit: number;
220
+ signal?: AbortSignal;
221
+ }): Promise<ToolSearchCandidate[]>;
222
+ }
223
+ //#endregion
224
+ export { ToolApproval as A, ConnectionToolPolicy as C, ToolProviderContext as D, ToolProvider as E, ToolRetryPolicy as F, ToolRisk as I, defineTool as L, ToolExecutionContext as M, ToolIdempotency as N, ToolProviderTool as O, ToolResult as P, toToolSpec as R, ConnectionDefinition as S, IntegrationErrorCategory as T, FevexJsonSchemaProfileLimits as _, InMemoryToolEmbeddingCacheOptions as a, compileFevexJsonSchema as b, ToolEmbeddingIndexEntry as c, cosineSimilarity as d, schemaKeywords as f, FEVEX_JSON_SCHEMA_PROFILE_VERSION as g, toolEmbeddingText as h, InMemoryToolEmbeddingCache as i, ToolDefinition as j, defineConnection as k, ToolEmbeddingMatch as l, toolEmbeddingKey as m, ToolSearchCandidate as n, ToolEmbeddingCache as o, searchToolEmbeddingIndex as p, BuildToolEmbeddingIndexOptions as r, ToolEmbeddingIndex as s, ToolReranker as t, buildToolEmbeddingIndex as u, FevexJsonSchemaProfileOptions as v, IntegrationError as w, validateFevexJsonSchemaProfile as x, FevexJsonSchemaValidator as y, ExactDefinition as z };
@@ -0,0 +1,73 @@
1
+ import { f as RunId, l as JsonValue, o as ExecutionContext } from "./types-CckDlhYo.mjs";
2
+ //#region src/sandbox/sandbox.d.ts
3
+ interface SandboxCapabilities {
4
+ process?: {
5
+ commands?: readonly string[];
6
+ timeoutMs?: number;
7
+ };
8
+ filesystem?: {
9
+ cwd?: string;
10
+ read?: readonly string[];
11
+ write?: readonly string[];
12
+ };
13
+ network?: false | {
14
+ allow?: readonly string[];
15
+ };
16
+ resources?: {
17
+ timeoutMs?: number;
18
+ maxOutputBytes?: number;
19
+ };
20
+ }
21
+ interface SandboxRunRequest {
22
+ command: string;
23
+ args?: readonly string[];
24
+ cwd?: string;
25
+ env?: Record<string, string>;
26
+ input?: string;
27
+ timeoutMs?: number;
28
+ maxOutputBytes?: number;
29
+ capabilities?: SandboxCapabilities;
30
+ runId?: RunId;
31
+ toolCallId?: string;
32
+ attempt?: number;
33
+ idempotencyKey?: string;
34
+ context?: ExecutionContext;
35
+ signal?: AbortSignal;
36
+ }
37
+ interface SandboxRunResult {
38
+ exitCode: number | null;
39
+ stdout: string;
40
+ stderr: string;
41
+ durationMs: number;
42
+ timedOut: boolean;
43
+ }
44
+ interface Sandbox {
45
+ run(request: SandboxRunRequest): Promise<SandboxRunResult>;
46
+ /**
47
+ * Release per-run resources (containers, workspaces) after a terminal run.
48
+ * Paired runs may keep their resources so a resume can continue.
49
+ */
50
+ cleanupRun?(runId: RunId): void | Promise<void>;
51
+ /** Release provider-wide resources during runtime shutdown. */
52
+ dispose?(): void | Promise<void>;
53
+ }
54
+ declare class SandboxError extends Error {
55
+ readonly code: string;
56
+ readonly safeMessage: string;
57
+ readonly name = "SandboxError";
58
+ constructor(code: string, safeMessage: string, options?: ErrorOptions);
59
+ }
60
+ declare function sandboxResultToJson(result: SandboxRunResult): JsonValue;
61
+ //#endregion
62
+ //#region src/sandbox/local-sandbox.d.ts
63
+ interface LocalSandboxOptions {
64
+ rootDir: string;
65
+ commands: readonly string[];
66
+ defaultTimeoutMs?: number;
67
+ maxOutputBytes?: number;
68
+ env?: Record<string, string>;
69
+ }
70
+ /** Creates a subprocess sandbox restricted to a root directory and command allowlist. */
71
+ declare function createLocalSandbox(options: LocalSandboxOptions): Sandbox;
72
+ //#endregion
73
+ export { SandboxError as a, sandboxResultToJson as c, SandboxCapabilities as i, createLocalSandbox as n, SandboxRunRequest as o, Sandbox as r, SandboxRunResult as s, LocalSandboxOptions as t };