@falai/agent 2.1.1 → 2.2.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/LICENSE +21 -0
- package/dist/adapters/SQLiteAdapter.d.ts +3 -3
- package/dist/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/cjs/adapters/SQLiteAdapter.d.ts +3 -3
- package/dist/cjs/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/index.d.ts +1 -1
- package/dist/cjs/adapters/index.d.ts.map +1 -1
- package/dist/cjs/core/BranchEvaluator.d.ts +2 -2
- package/dist/cjs/core/BranchEvaluator.js +2 -2
- package/dist/cjs/core/BranchEvaluator.js.map +1 -1
- package/dist/cjs/core/Flow.d.ts +3 -7
- package/dist/cjs/core/Flow.d.ts.map +1 -1
- package/dist/cjs/core/Flow.js +2 -8
- package/dist/cjs/core/Flow.js.map +1 -1
- package/dist/cjs/core/FlowRouter.js +2 -2
- package/dist/cjs/core/FlowRouter.js.map +1 -1
- package/dist/cjs/core/PromptComposer.d.ts.map +1 -1
- package/dist/cjs/core/PromptComposer.js +8 -20
- package/dist/cjs/core/PromptComposer.js.map +1 -1
- package/dist/cjs/core/PromptSectionCache.d.ts +2 -11
- package/dist/cjs/core/PromptSectionCache.d.ts.map +1 -1
- package/dist/cjs/core/PromptSectionCache.js.map +1 -1
- package/dist/cjs/core/ResponseModal.d.ts +5 -5
- package/dist/cjs/core/ResponseModal.d.ts.map +1 -1
- package/dist/cjs/core/ResponseModal.js +38 -182
- package/dist/cjs/core/ResponseModal.js.map +1 -1
- package/dist/cjs/core/Step.d.ts +2 -1
- package/dist/cjs/core/Step.d.ts.map +1 -1
- package/dist/cjs/core/Step.js +2 -1
- package/dist/cjs/core/Step.js.map +1 -1
- package/dist/cjs/core/ToolManager.d.ts +1 -33
- package/dist/cjs/core/ToolManager.d.ts.map +1 -1
- package/dist/cjs/core/ToolManager.js +2 -189
- package/dist/cjs/core/ToolManager.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/agent.d.ts +6 -11
- package/dist/cjs/types/agent.d.ts.map +1 -1
- package/dist/cjs/types/agent.js +0 -9
- package/dist/cjs/types/agent.js.map +1 -1
- package/dist/cjs/types/flow.d.ts +4 -4
- package/dist/cjs/types/history.d.ts +0 -2
- package/dist/cjs/types/history.d.ts.map +1 -1
- package/dist/cjs/types/history.js.map +1 -1
- package/dist/cjs/types/index.d.ts +1 -6
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +1 -20
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/prompt-cache.d.ts +15 -0
- package/dist/cjs/types/prompt-cache.d.ts.map +1 -0
- package/dist/cjs/types/prompt-cache.js +6 -0
- package/dist/cjs/types/prompt-cache.js.map +1 -0
- package/dist/cjs/types/schema.d.ts +0 -7
- package/dist/cjs/types/schema.d.ts.map +1 -1
- package/dist/cjs/types/tool.d.ts.map +1 -1
- package/dist/cjs/utils/history.d.ts +0 -5
- package/dist/cjs/utils/history.d.ts.map +1 -1
- package/dist/cjs/utils/history.js +0 -8
- package/dist/cjs/utils/history.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +2 -2
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +1 -4
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/template.d.ts +0 -2
- package/dist/cjs/utils/template.d.ts.map +1 -1
- package/dist/cjs/utils/template.js +0 -2
- package/dist/cjs/utils/template.js.map +1 -1
- package/dist/core/BranchEvaluator.d.ts +2 -2
- package/dist/core/BranchEvaluator.js +2 -2
- package/dist/core/BranchEvaluator.js.map +1 -1
- package/dist/core/Flow.d.ts +3 -7
- package/dist/core/Flow.d.ts.map +1 -1
- package/dist/core/Flow.js +2 -8
- package/dist/core/Flow.js.map +1 -1
- package/dist/core/FlowRouter.js +2 -2
- package/dist/core/FlowRouter.js.map +1 -1
- package/dist/core/PromptComposer.d.ts.map +1 -1
- package/dist/core/PromptComposer.js +8 -20
- package/dist/core/PromptComposer.js.map +1 -1
- package/dist/core/PromptSectionCache.d.ts +2 -11
- package/dist/core/PromptSectionCache.d.ts.map +1 -1
- package/dist/core/PromptSectionCache.js.map +1 -1
- package/dist/core/ResponseModal.d.ts +5 -5
- package/dist/core/ResponseModal.d.ts.map +1 -1
- package/dist/core/ResponseModal.js +38 -182
- package/dist/core/ResponseModal.js.map +1 -1
- package/dist/core/Step.d.ts +2 -1
- package/dist/core/Step.d.ts.map +1 -1
- package/dist/core/Step.js +2 -1
- package/dist/core/Step.js.map +1 -1
- package/dist/core/ToolManager.d.ts +1 -33
- package/dist/core/ToolManager.d.ts.map +1 -1
- package/dist/core/ToolManager.js +2 -189
- package/dist/core/ToolManager.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/agent.d.ts +6 -11
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/agent.js +1 -8
- package/dist/types/agent.js.map +1 -1
- package/dist/types/flow.d.ts +4 -4
- package/dist/types/history.d.ts +0 -2
- package/dist/types/history.d.ts.map +1 -1
- package/dist/types/history.js.map +1 -1
- package/dist/types/index.d.ts +1 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +1 -1
- package/dist/types/prompt-cache.d.ts +15 -0
- package/dist/types/prompt-cache.d.ts.map +1 -0
- package/dist/types/prompt-cache.js +5 -0
- package/dist/types/prompt-cache.js.map +1 -0
- package/dist/types/schema.d.ts +0 -7
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/tool.d.ts.map +1 -1
- package/dist/utils/history.d.ts +0 -5
- package/dist/utils/history.d.ts.map +1 -1
- package/dist/utils/history.js +0 -7
- package/dist/utils/history.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/template.d.ts +0 -2
- package/dist/utils/template.d.ts.map +1 -1
- package/dist/utils/template.js +0 -2
- package/dist/utils/template.js.map +1 -1
- package/docs/guides/branching.md +3 -1
- package/docs/guides/conditions.md +9 -8
- package/docs/guides/instructions.md +7 -7
- package/docs/reference/branches.md +2 -2
- package/docs/reference/flow.md +1 -1
- package/docs/reference/instruction.md +7 -5
- package/docs/reference/step.md +2 -2
- package/package.json +17 -27
- package/src/adapters/SQLiteAdapter.ts +3 -3
- package/src/adapters/index.ts +1 -1
- package/src/core/BranchEvaluator.ts +4 -4
- package/src/core/Flow.ts +2 -10
- package/src/core/FlowRouter.ts +2 -2
- package/src/core/PromptComposer.ts +9 -20
- package/src/core/PromptSectionCache.ts +2 -13
- package/src/core/ResponseModal.ts +39 -197
- package/src/core/Step.ts +2 -1
- package/src/core/ToolManager.ts +2 -234
- package/src/index.ts +2 -3
- package/src/types/agent.ts +6 -12
- package/src/types/flow.ts +4 -4
- package/src/types/history.ts +0 -4
- package/src/types/index.ts +2 -9
- package/src/types/prompt-cache.ts +17 -0
- package/src/types/schema.ts +0 -8
- package/src/types/tool.ts +0 -2
- package/src/utils/history.ts +1 -7
- package/src/utils/index.ts +0 -3
- package/src/utils/template.ts +0 -2
- package/dist/cjs/types/routing.d.ts +0 -12
- package/dist/cjs/types/routing.d.ts.map +0 -1
- package/dist/cjs/types/routing.js +0 -3
- package/dist/cjs/types/routing.js.map +0 -1
- package/dist/types/routing.d.ts +0 -12
- package/dist/types/routing.d.ts.map +0 -1
- package/dist/types/routing.js +0 -2
- package/dist/types/routing.js.map +0 -1
- package/src/types/routing.ts +0 -13
package/src/types/flow.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type ConditionIf<TContext = unknown, TData = unknown> =
|
|
|
25
25
|
| ConditionPredicate<TContext, TData>[];
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* The `when` field shape: a single AI-evaluated string or array of strings (
|
|
28
|
+
* The `when` field shape: a single AI-evaluated string or array of strings (OR semantics).
|
|
29
29
|
* Functions are NOT allowed on `when` — they belong on `if` only.
|
|
30
30
|
*/
|
|
31
31
|
export type ConditionWhen = string | string[];
|
|
@@ -196,7 +196,7 @@ export type BranchPredicate<TContext = unknown, TData = unknown> = (
|
|
|
196
196
|
*/
|
|
197
197
|
export interface BranchEntry<TContext = unknown, TData = unknown> {
|
|
198
198
|
/**
|
|
199
|
-
* AI-evaluated condition. String or array of strings (
|
|
199
|
+
* AI-evaluated condition. String or array of strings (OR semantics).
|
|
200
200
|
* Costs LLM tokens. Reuses the same machinery as `step.when`.
|
|
201
201
|
* Only evaluated if `if` passes (or is absent) — code-first short-circuit.
|
|
202
202
|
*/
|
|
@@ -324,7 +324,7 @@ export interface FlowOptions<TContext = unknown, TData = unknown> {
|
|
|
324
324
|
description?: string;
|
|
325
325
|
|
|
326
326
|
/**
|
|
327
|
-
* AI-evaluated activation condition(s). String or array of strings (
|
|
327
|
+
* AI-evaluated activation condition(s). String or array of strings (OR semantics).
|
|
328
328
|
* Costs LLM tokens. Functions are NOT allowed here — use `if` for code predicates.
|
|
329
329
|
*/
|
|
330
330
|
when?: ConditionWhen;
|
|
@@ -498,7 +498,7 @@ export interface StepOptions<TContext = unknown, TData = unknown> {
|
|
|
498
498
|
*/
|
|
499
499
|
requires?: (keyof TData)[];
|
|
500
500
|
/**
|
|
501
|
-
* AI-evaluated activation condition(s). String or array of strings (
|
|
501
|
+
* AI-evaluated activation condition(s). String or array of strings (OR semantics).
|
|
502
502
|
* Costs LLM tokens. Functions are NOT allowed here — use `if` for code predicates.
|
|
503
503
|
*/
|
|
504
504
|
when?: ConditionWhen;
|
package/src/types/history.ts
CHANGED
|
@@ -16,8 +16,6 @@ export enum MessageRole {
|
|
|
16
16
|
SYSTEM = "system",
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export type MessageRoleType = MessageRole;
|
|
20
|
-
|
|
21
19
|
import type { SessionState } from "./session";
|
|
22
20
|
|
|
23
21
|
/**
|
|
@@ -32,8 +30,6 @@ export enum EventKind {
|
|
|
32
30
|
STATUS = "status",
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
export type EventKindType = EventKind;
|
|
36
|
-
|
|
37
33
|
/**
|
|
38
34
|
* Participant in a conversation
|
|
39
35
|
*/
|
package/src/types/index.ts
CHANGED
|
@@ -19,7 +19,6 @@ export type {
|
|
|
19
19
|
HookContext,
|
|
20
20
|
ExitReason,
|
|
21
21
|
} from "./agent";
|
|
22
|
-
export { CompositionMode } from "./agent";
|
|
23
22
|
|
|
24
23
|
// History types
|
|
25
24
|
export type {
|
|
@@ -41,7 +40,6 @@ export type {
|
|
|
41
40
|
ToolHistoryItem,
|
|
42
41
|
} from "./history";
|
|
43
42
|
export { EventKind, MessageRole } from "./history";
|
|
44
|
-
export * from "./history";
|
|
45
43
|
|
|
46
44
|
// Flow types
|
|
47
45
|
export type {
|
|
@@ -105,12 +103,12 @@ export type {
|
|
|
105
103
|
CompactionResult,
|
|
106
104
|
} from "./compaction";
|
|
107
105
|
|
|
108
|
-
// Prompt cache types
|
|
106
|
+
// Prompt cache types
|
|
109
107
|
export type {
|
|
110
108
|
PromptSectionType,
|
|
111
109
|
PromptCacheConfig,
|
|
112
110
|
SectionCompute,
|
|
113
|
-
} from "
|
|
111
|
+
} from "./prompt-cache";
|
|
114
112
|
|
|
115
113
|
// AI provider types
|
|
116
114
|
export type {
|
|
@@ -125,10 +123,6 @@ export type {
|
|
|
125
123
|
// Schema types
|
|
126
124
|
export type { StructuredSchema } from "./schema";
|
|
127
125
|
|
|
128
|
-
// Routing types
|
|
129
|
-
export type { RoutingDecision } from "./routing";
|
|
130
|
-
export * from "./routing";
|
|
131
|
-
|
|
132
126
|
// Persistence types
|
|
133
127
|
export type {
|
|
134
128
|
SessionData,
|
|
@@ -143,7 +137,6 @@ export type {
|
|
|
143
137
|
SaveMessageOptions,
|
|
144
138
|
CollectedStateData,
|
|
145
139
|
} from "./persistence";
|
|
146
|
-
export * from "./persistence";
|
|
147
140
|
|
|
148
141
|
// Template types
|
|
149
142
|
export type {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt section cache configuration types.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Section type: static sections are cached, dynamic sections recompute every turn */
|
|
6
|
+
export type PromptSectionType = "static" | "dynamic";
|
|
7
|
+
|
|
8
|
+
/** Configuration for prompt section caching behavior */
|
|
9
|
+
export interface PromptCacheConfig {
|
|
10
|
+
/** Whether to enable section memoization (default: true) */
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
/** Keys of sections that should always recompute every turn, even if registered as static */
|
|
13
|
+
volatileKeys?: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Compute function that produces a section's content */
|
|
17
|
+
export type SectionCompute = () => string | null | Promise<string | null>;
|
package/src/types/schema.ts
CHANGED
|
@@ -13,11 +13,3 @@ export interface StructuredSchema {
|
|
|
13
13
|
// Allow provider-specific passthroughs without breaking types
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A small helper describing a named schema (for providers that require a name)
|
|
19
|
-
*/
|
|
20
|
-
export interface NamedSchema {
|
|
21
|
-
name?: string;
|
|
22
|
-
schema: StructuredSchema;
|
|
23
|
-
}
|
package/src/types/tool.ts
CHANGED
package/src/utils/history.ts
CHANGED
|
@@ -258,13 +258,7 @@ export function eventsToHistory(events: Event[]): History {
|
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
|
|
262
|
-
* Normalize a simplified history array to internal Event array
|
|
263
|
-
* @deprecated Use historyToEvents instead
|
|
264
|
-
*/
|
|
265
|
-
export function normalizeHistory(history: History): Event[] {
|
|
266
|
-
return historyToEvents(history);
|
|
267
|
-
}
|
|
261
|
+
|
|
268
262
|
|
|
269
263
|
/**
|
|
270
264
|
* Helper function to create a user message
|
package/src/utils/index.ts
CHANGED
|
@@ -29,8 +29,6 @@ export {
|
|
|
29
29
|
export {
|
|
30
30
|
render,
|
|
31
31
|
renderMany,
|
|
32
|
-
renderTemplate,
|
|
33
|
-
renderTemplateObject,
|
|
34
32
|
formatKnowledgeBase,
|
|
35
33
|
createTemplateContext,
|
|
36
34
|
} from "./template";
|
|
@@ -43,7 +41,6 @@ export { getLastMessageFromHistory } from "./event";
|
|
|
43
41
|
|
|
44
42
|
// History utilities
|
|
45
43
|
export {
|
|
46
|
-
normalizeHistory,
|
|
47
44
|
historyItemToEvent,
|
|
48
45
|
historyToEvents,
|
|
49
46
|
eventToHistoryItem,
|
package/src/utils/template.ts
CHANGED
|
@@ -59,7 +59,6 @@ export async function renderMany<TContext = unknown, TData = unknown>(
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @deprecated Use the asynchronous `render` function instead.
|
|
63
62
|
* Renders template variables in a string using the provided context.
|
|
64
63
|
* Supports {{variable}} and {{object.property}} syntax for property access.
|
|
65
64
|
*
|
|
@@ -171,7 +170,6 @@ function valueToString(value: unknown): string {
|
|
|
171
170
|
}
|
|
172
171
|
|
|
173
172
|
/**
|
|
174
|
-
* @deprecated This function does not support async template functions.
|
|
175
173
|
* Renders template variables in an object recursively.
|
|
176
174
|
* Handles nested objects and arrays.
|
|
177
175
|
*
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StructuredSchema } from "./schema";
|
|
2
|
-
export interface RoutingDecision {
|
|
3
|
-
context: string;
|
|
4
|
-
flows: Record<string, number>;
|
|
5
|
-
responseDirectives?: string[];
|
|
6
|
-
extractions?: unknown;
|
|
7
|
-
contextUpdate?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
export interface RoutingSchemaOptions {
|
|
10
|
-
extrasSchema?: StructuredSchema;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/types/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/types/routing.ts"],"names":[],"mappings":""}
|
package/dist/types/routing.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StructuredSchema } from "./schema";
|
|
2
|
-
export interface RoutingDecision {
|
|
3
|
-
context: string;
|
|
4
|
-
flows: Record<string, number>;
|
|
5
|
-
responseDirectives?: string[];
|
|
6
|
-
extractions?: unknown;
|
|
7
|
-
contextUpdate?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
export interface RoutingSchemaOptions {
|
|
10
|
-
extrasSchema?: StructuredSchema;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/types/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC"}
|
package/dist/types/routing.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/types/routing.ts"],"names":[],"mappings":""}
|
package/src/types/routing.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { StructuredSchema } from "./schema";
|
|
2
|
-
|
|
3
|
-
export interface RoutingDecision {
|
|
4
|
-
context: string;
|
|
5
|
-
flows: Record<string, number>;
|
|
6
|
-
responseDirectives?: string[];
|
|
7
|
-
extractions?: unknown;
|
|
8
|
-
contextUpdate?: Record<string, unknown>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RoutingSchemaOptions {
|
|
12
|
-
extrasSchema?: StructuredSchema;
|
|
13
|
-
}
|