@falai/agent 0.1.3 → 0.1.4
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/dist/cjs/constants/index.d.ts +5 -0
- package/dist/cjs/constants/index.d.ts.map +1 -0
- package/dist/cjs/constants/index.js +8 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/core/Agent.d.ts +110 -0
- package/dist/cjs/core/Agent.d.ts.map +1 -0
- package/dist/cjs/core/Agent.js +290 -0
- package/dist/cjs/core/Agent.js.map +1 -0
- package/dist/cjs/core/DomainRegistry.d.ts +26 -0
- package/dist/cjs/core/DomainRegistry.d.ts.map +1 -0
- package/dist/cjs/core/DomainRegistry.js +47 -0
- package/dist/cjs/core/DomainRegistry.js.map +1 -0
- package/dist/cjs/core/Events.d.ts +19 -0
- package/dist/cjs/core/Events.d.ts.map +1 -0
- package/dist/cjs/core/Events.js +84 -0
- package/dist/cjs/core/Events.js.map +1 -0
- package/dist/cjs/core/Observation.d.ts +24 -0
- package/dist/cjs/core/Observation.d.ts.map +1 -0
- package/dist/cjs/core/Observation.js +38 -0
- package/dist/cjs/core/Observation.js.map +1 -0
- package/dist/cjs/core/PromptBuilder.d.ts +125 -0
- package/dist/cjs/core/PromptBuilder.d.ts.map +1 -0
- package/dist/cjs/core/PromptBuilder.js +374 -0
- package/dist/cjs/core/PromptBuilder.js.map +1 -0
- package/dist/cjs/core/Route.d.ts +46 -0
- package/dist/cjs/core/Route.d.ts.map +1 -0
- package/dist/cjs/core/Route.js +112 -0
- package/dist/cjs/core/Route.js.map +1 -0
- package/dist/cjs/core/State.d.ts +50 -0
- package/dist/cjs/core/State.d.ts.map +1 -0
- package/dist/cjs/core/State.js +111 -0
- package/dist/cjs/core/State.js.map +1 -0
- package/dist/cjs/core/Tool.d.ts +31 -0
- package/dist/cjs/core/Tool.d.ts.map +1 -0
- package/dist/cjs/core/Tool.js +36 -0
- package/dist/cjs/core/Tool.js.map +1 -0
- package/dist/cjs/core/Transition.d.ts +32 -0
- package/dist/cjs/core/Transition.d.ts.map +1 -0
- package/dist/cjs/core/Transition.js +59 -0
- package/dist/cjs/core/Transition.js.map +1 -0
- package/dist/cjs/index.d.ts +34 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/providers/GeminiProvider.d.ts +40 -0
- package/dist/cjs/providers/GeminiProvider.d.ts.map +1 -0
- package/dist/cjs/providers/GeminiProvider.js +142 -0
- package/dist/cjs/providers/GeminiProvider.js.map +1 -0
- package/dist/cjs/providers/OpenAIProvider.d.ts +42 -0
- package/dist/cjs/providers/OpenAIProvider.d.ts.map +1 -0
- package/dist/cjs/providers/OpenAIProvider.js +242 -0
- package/dist/cjs/providers/OpenAIProvider.js.map +1 -0
- package/dist/cjs/providers/OpenRouterProvider.d.ts +46 -0
- package/dist/cjs/providers/OpenRouterProvider.d.ts.map +1 -0
- package/dist/cjs/providers/OpenRouterProvider.js +249 -0
- package/dist/cjs/providers/OpenRouterProvider.js.map +1 -0
- package/dist/cjs/types/agent.d.ts +105 -0
- package/dist/cjs/types/agent.d.ts.map +1 -0
- package/dist/cjs/types/agent.js +21 -0
- package/dist/cjs/types/agent.js.map +1 -0
- package/dist/cjs/types/ai.d.ts +102 -0
- package/dist/cjs/types/ai.d.ts.map +1 -0
- package/dist/cjs/types/ai.js +6 -0
- package/dist/cjs/types/ai.js.map +1 -0
- package/dist/cjs/types/history.d.ts +112 -0
- package/dist/cjs/types/history.d.ts.map +1 -0
- package/dist/cjs/types/history.js +37 -0
- package/dist/cjs/types/history.js.map +1 -0
- package/dist/cjs/types/index.d.ts +14 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +14 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/observation.d.ts +25 -0
- package/dist/cjs/types/observation.d.ts.map +1 -0
- package/dist/cjs/types/observation.js +6 -0
- package/dist/cjs/types/observation.js.map +1 -0
- package/dist/cjs/types/prompt.d.ts +46 -0
- package/dist/cjs/types/prompt.d.ts.map +1 -0
- package/dist/cjs/types/prompt.js +19 -0
- package/dist/cjs/types/prompt.js.map +1 -0
- package/dist/cjs/types/route.d.ts +59 -0
- package/dist/cjs/types/route.d.ts.map +1 -0
- package/dist/cjs/types/route.js +6 -0
- package/dist/cjs/types/route.js.map +1 -0
- package/dist/cjs/types/tool.d.ts +46 -0
- package/dist/cjs/types/tool.d.ts.map +1 -0
- package/dist/cjs/types/tool.js +6 -0
- package/dist/cjs/types/tool.js.map +1 -0
- package/dist/cjs/utils/retry.d.ts +13 -0
- package/dist/cjs/utils/retry.d.ts.map +1 -0
- package/dist/cjs/utils/retry.js +75 -0
- package/dist/cjs/utils/retry.js.map +1 -0
- package/dist/core/Agent.js +10 -11
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/DomainRegistry.js +3 -1
- package/dist/core/DomainRegistry.js.map +1 -1
- package/dist/core/Observation.js +1 -3
- package/dist/core/Observation.js.map +1 -1
- package/dist/core/PromptBuilder.js +2 -3
- package/dist/core/PromptBuilder.js.map +1 -1
- package/dist/core/Route.js +1 -6
- package/dist/core/Route.js.map +1 -1
- package/dist/core/State.js +2 -5
- package/dist/core/State.js.map +1 -1
- package/dist/core/Transition.js +0 -4
- package/dist/core/Transition.js.map +1 -1
- package/dist/providers/GeminiProvider.js +1 -6
- package/dist/providers/GeminiProvider.js.map +1 -1
- package/dist/providers/OpenAIProvider.js +1 -6
- package/dist/providers/OpenAIProvider.js.map +1 -1
- package/dist/providers/OpenRouterProvider.js +1 -6
- package/dist/providers/OpenRouterProvider.js.map +1 -1
- package/package.json +15 -5
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Route (Journey) DSL implementation
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Route = void 0;
|
|
7
|
+
const State_1 = require("./State");
|
|
8
|
+
let routeIdCounter = 0;
|
|
9
|
+
/**
|
|
10
|
+
* Represents a conversational route/journey
|
|
11
|
+
*/
|
|
12
|
+
class Route {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.guidelines = [];
|
|
15
|
+
this.id = `route_${++routeIdCounter}_${options.title
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.replace(/\s+/g, "_")}`;
|
|
18
|
+
this.title = options.title;
|
|
19
|
+
this.description = options.description;
|
|
20
|
+
this.conditions = options.conditions || [];
|
|
21
|
+
this.initialState = new State_1.State(this.id, "Initial state");
|
|
22
|
+
// Initialize guidelines from options
|
|
23
|
+
if (options.guidelines) {
|
|
24
|
+
options.guidelines.forEach((guideline) => {
|
|
25
|
+
this.createGuideline(guideline);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a guideline specific to this route
|
|
31
|
+
*/
|
|
32
|
+
createGuideline(guideline) {
|
|
33
|
+
this.guidelines.push({
|
|
34
|
+
...guideline,
|
|
35
|
+
id: guideline.id || `guideline_${this.id}_${this.guidelines.length}`,
|
|
36
|
+
enabled: guideline.enabled !== false, // Default to true
|
|
37
|
+
});
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get all guidelines for this route
|
|
42
|
+
*/
|
|
43
|
+
getGuidelines() {
|
|
44
|
+
return [...this.guidelines];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get route reference
|
|
48
|
+
*/
|
|
49
|
+
getRef() {
|
|
50
|
+
return {
|
|
51
|
+
id: this.id,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a route reference that includes this route instance
|
|
56
|
+
* Useful for disambiguation
|
|
57
|
+
*/
|
|
58
|
+
toRef() {
|
|
59
|
+
return {
|
|
60
|
+
id: this.id,
|
|
61
|
+
route: this,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get all states in this route (via traversal from initial state)
|
|
66
|
+
*/
|
|
67
|
+
getAllStates() {
|
|
68
|
+
const visited = new Set();
|
|
69
|
+
const states = [];
|
|
70
|
+
const queue = [this.initialState];
|
|
71
|
+
while (queue.length > 0) {
|
|
72
|
+
const current = queue.shift();
|
|
73
|
+
if (visited.has(current.id)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
visited.add(current.id);
|
|
77
|
+
states.push(current);
|
|
78
|
+
// Add target states from transitions
|
|
79
|
+
for (const transition of current.getTransitions()) {
|
|
80
|
+
const target = transition.getTarget();
|
|
81
|
+
if (target && !visited.has(target.id)) {
|
|
82
|
+
queue.push(target);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return states;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get a description of the route structure for debugging
|
|
90
|
+
*/
|
|
91
|
+
describe() {
|
|
92
|
+
const lines = [
|
|
93
|
+
`Route: ${this.title}`,
|
|
94
|
+
`ID: ${this.id}`,
|
|
95
|
+
`Description: ${this.description || "N/A"}`,
|
|
96
|
+
`Conditions: ${this.conditions.join(", ") || "None"}`,
|
|
97
|
+
"",
|
|
98
|
+
"States:",
|
|
99
|
+
];
|
|
100
|
+
const states = this.getAllStates();
|
|
101
|
+
for (const state of states) {
|
|
102
|
+
lines.push(` - ${state.id}${state.description ? `: ${state.description}` : ""}`);
|
|
103
|
+
const transitions = state.getTransitions();
|
|
104
|
+
for (const transition of transitions) {
|
|
105
|
+
lines.push(` -> ${transition.describe()}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return lines.join("\n");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.Route = Route;
|
|
112
|
+
//# sourceMappingURL=Route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Route.js","source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C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE;YACrD,EAAE;YACF,SAAS;SACV,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CACR,OAAO,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACtE,CAAC;YAEF,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;YAC3C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,KAAK,CAAC,IAAI,CAAC,UAAU,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAzHD,sBAyHC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State in the route DSL
|
|
3
|
+
*/
|
|
4
|
+
import type { StateRef, TransitionSpec, TransitionResult } from "../types/route";
|
|
5
|
+
import type { Guideline } from "../types/agent";
|
|
6
|
+
import { Transition } from "./Transition";
|
|
7
|
+
/**
|
|
8
|
+
* Represents a state within a route
|
|
9
|
+
*/
|
|
10
|
+
export declare class State<TContext = unknown> {
|
|
11
|
+
readonly routeId: string;
|
|
12
|
+
readonly description?: string | undefined;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
private transitions;
|
|
15
|
+
private guidelines;
|
|
16
|
+
constructor(routeId: string, description?: string | undefined);
|
|
17
|
+
/**
|
|
18
|
+
* Create a transition from this state to another
|
|
19
|
+
*
|
|
20
|
+
* @param spec - Transition specification (chatState, toolState, or direct state)
|
|
21
|
+
* @param condition - Optional condition for this transition
|
|
22
|
+
* @returns Object with target state that supports chaining
|
|
23
|
+
*/
|
|
24
|
+
transitionTo(spec: TransitionSpec<TContext>, condition?: string): TransitionResult<TContext>;
|
|
25
|
+
/**
|
|
26
|
+
* Add a guideline specific to this state
|
|
27
|
+
*/
|
|
28
|
+
addGuideline(guideline: Guideline): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get guidelines for this state
|
|
31
|
+
*/
|
|
32
|
+
getGuidelines(): Guideline[];
|
|
33
|
+
/**
|
|
34
|
+
* Get all transitions from this state
|
|
35
|
+
*/
|
|
36
|
+
getTransitions(): Transition<TContext>[];
|
|
37
|
+
/**
|
|
38
|
+
* Get state reference
|
|
39
|
+
*/
|
|
40
|
+
getRef(): StateRef;
|
|
41
|
+
/**
|
|
42
|
+
* Create a state reference with transitionTo capability for chaining
|
|
43
|
+
*/
|
|
44
|
+
private createStateRefWithTransition;
|
|
45
|
+
/**
|
|
46
|
+
* Create a terminal state reference (for END_ROUTE)
|
|
47
|
+
*/
|
|
48
|
+
private createTerminalRef;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=State.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/core/State.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C;;GAEG;AACH,qBAAa,KAAK,CAAC,QAAQ,GAAG,OAAO;aAMjB,OAAO,EAAE,MAAM;aACf,WAAW,CAAC,EAAE,MAAM;IANtC,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,UAAU,CAAmB;gBAGnB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,YAAA;IAKtC;;;;;;OAMG;IACH,YAAY,CACV,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,EAC9B,SAAS,CAAC,EAAE,MAAM,GACjB,gBAAgB,CAAC,QAAQ,CAAC;IAiD7B;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIxC;;OAEG;IACH,aAAa,IAAI,SAAS,EAAE;IAI5B;;OAEG;IACH,cAAc,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE;IAIxC;;OAEG;IACH,MAAM,IAAI,QAAQ;IAOlB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAkBpC;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAkB1B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* State in the route DSL
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.State = void 0;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const Transition_1 = require("./Transition");
|
|
9
|
+
let stateIdCounter = 0;
|
|
10
|
+
/**
|
|
11
|
+
* Represents a state within a route
|
|
12
|
+
*/
|
|
13
|
+
class State {
|
|
14
|
+
constructor(routeId, description) {
|
|
15
|
+
this.routeId = routeId;
|
|
16
|
+
this.description = description;
|
|
17
|
+
this.transitions = [];
|
|
18
|
+
this.guidelines = [];
|
|
19
|
+
this.id = `state_${++stateIdCounter}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a transition from this state to another
|
|
23
|
+
*
|
|
24
|
+
* @param spec - Transition specification (chatState, toolState, or direct state)
|
|
25
|
+
* @param condition - Optional condition for this transition
|
|
26
|
+
* @returns Object with target state that supports chaining
|
|
27
|
+
*/
|
|
28
|
+
transitionTo(spec, condition) {
|
|
29
|
+
// Handle END_ROUTE
|
|
30
|
+
if (spec.state &&
|
|
31
|
+
typeof spec.state === "symbol" &&
|
|
32
|
+
spec.state === constants_1.END_ROUTE) {
|
|
33
|
+
const endTransition = new Transition_1.Transition(this.getRef(), { state: constants_1.END_ROUTE }, condition);
|
|
34
|
+
this.transitions.push(endTransition);
|
|
35
|
+
// Return a terminal state reference
|
|
36
|
+
return {
|
|
37
|
+
target: this.createTerminalRef(),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Handle direct state reference
|
|
41
|
+
if (spec.state && typeof spec.state !== "symbol") {
|
|
42
|
+
const transition = new Transition_1.Transition(this.getRef(), spec, condition);
|
|
43
|
+
this.transitions.push(transition);
|
|
44
|
+
return {
|
|
45
|
+
target: this.createStateRefWithTransition(spec.state),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Create new target state for chatState or toolState
|
|
49
|
+
const targetState = new State(this.routeId, spec.chatState);
|
|
50
|
+
const transition = new Transition_1.Transition(this.getRef(), spec, condition);
|
|
51
|
+
transition.setTarget(targetState);
|
|
52
|
+
this.transitions.push(transition);
|
|
53
|
+
return {
|
|
54
|
+
target: this.createStateRefWithTransition(targetState.getRef(), targetState),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Add a guideline specific to this state
|
|
59
|
+
*/
|
|
60
|
+
addGuideline(guideline) {
|
|
61
|
+
this.guidelines.push(guideline);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get guidelines for this state
|
|
65
|
+
*/
|
|
66
|
+
getGuidelines() {
|
|
67
|
+
return [...this.guidelines];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all transitions from this state
|
|
71
|
+
*/
|
|
72
|
+
getTransitions() {
|
|
73
|
+
return [...this.transitions];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get state reference
|
|
77
|
+
*/
|
|
78
|
+
getRef() {
|
|
79
|
+
return {
|
|
80
|
+
id: this.id,
|
|
81
|
+
routeId: this.routeId,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a state reference with transitionTo capability for chaining
|
|
86
|
+
*/
|
|
87
|
+
createStateRefWithTransition(ref, state) {
|
|
88
|
+
const stateInstance = state || this;
|
|
89
|
+
return {
|
|
90
|
+
...ref,
|
|
91
|
+
transitionTo: (spec, condition) => stateInstance.transitionTo(spec, condition),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a terminal state reference (for END_ROUTE)
|
|
96
|
+
*/
|
|
97
|
+
createTerminalRef() {
|
|
98
|
+
const terminalRef = {
|
|
99
|
+
id: "END",
|
|
100
|
+
routeId: this.routeId,
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
...terminalRef,
|
|
104
|
+
transitionTo: () => {
|
|
105
|
+
throw new Error("Cannot transition from END_ROUTE state");
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.State = State;
|
|
111
|
+
//# sourceMappingURL=State.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"State.js","sourceRoot":"","sources":["../../../src/core/State.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AASH,4CAAyC;AACzC,6CAA0C;AAE1C,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAa,KAAK;IAKhB,YACkB,OAAe,EACf,WAAoB;QADpB,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAS;QAL9B,gBAAW,GAA2B,EAAE,CAAC;QACzC,eAAU,GAAgB,EAAE,CAAC;QAMnC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,cAAc,EAAE,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CACV,IAA8B,EAC9B,SAAkB;QAElB,mBAAmB;QACnB,IACE,IAAI,CAAC,KAAK;YACV,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;YAC9B,IAAI,C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IAED;;OAEG;IACH,aAAa;QACX,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,4BAA4B,CAClC,GAAa,EACb,KAAuB;QAOvB,MAAM,aAAa,GAAG,KAAK,IAAI,IAAI,CAAC;QAEpC,OAAO;YACL,GAAG,GAAG;YACN,YAAY,EAAE,CAAC,IAA8B,EAAE,SAAkB,EAAE,EAAE,CACnE,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC;SAC9C,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,iBAAiB;QAMvB,MAAM,WAAW,GAAa;YAC5B,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;QAEF,OAAO;YACL,GAAG,WAAW;YACd,YAAY,EAAE,GAAG,EAAE;gBACjB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAhJD,sBAgJC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition and creation utilities
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolContext, ToolHandler, ToolRef, ToolResult } from "../types/tool";
|
|
5
|
+
/**
|
|
6
|
+
* Define a new tool with type-safe context and arguments
|
|
7
|
+
*
|
|
8
|
+
* @param name - Name of the tool
|
|
9
|
+
* @param handler - Handler function that executes the tool
|
|
10
|
+
* @param options - Optional configuration
|
|
11
|
+
* @returns A reference to the defined tool
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const getTool = defineTool<MyContext, [string, number], string>(
|
|
16
|
+
* 'get_data',
|
|
17
|
+
* async ({ context }, id, count) => {
|
|
18
|
+
* return { data: `Retrieved ${count} items for ${id}` };
|
|
19
|
+
* }
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function defineTool<TContext, TArgs extends unknown[], TResult>(name: string, handler: ToolHandler<TContext, TArgs, TResult>, options?: {
|
|
24
|
+
description?: string;
|
|
25
|
+
parameters?: unknown;
|
|
26
|
+
}): ToolRef<TContext, TArgs, TResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Re-export types for convenience
|
|
29
|
+
*/
|
|
30
|
+
export type { ToolContext, ToolHandler, ToolRef, ToolResult };
|
|
31
|
+
//# sourceMappingURL=Tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tool.d.ts","sourceRoot":"","sources":["../../../src/core/Tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACX,MAAM,eAAe,CAAC;AAIvB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACnE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,EAC9C,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAUnC;AAED;;GAEG;AACH,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool definition and creation utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defineTool = defineTool;
|
|
7
|
+
let toolIdCounter = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Define a new tool with type-safe context and arguments
|
|
10
|
+
*
|
|
11
|
+
* @param name - Name of the tool
|
|
12
|
+
* @param handler - Handler function that executes the tool
|
|
13
|
+
* @param options - Optional configuration
|
|
14
|
+
* @returns A reference to the defined tool
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const getTool = defineTool<MyContext, [string, number], string>(
|
|
19
|
+
* 'get_data',
|
|
20
|
+
* async ({ context }, id, count) => {
|
|
21
|
+
* return { data: `Retrieved ${count} items for ${id}` };
|
|
22
|
+
* }
|
|
23
|
+
* );
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function defineTool(name, handler, options) {
|
|
27
|
+
const id = `tool_${++toolIdCounter}_${name}`;
|
|
28
|
+
return {
|
|
29
|
+
id,
|
|
30
|
+
name,
|
|
31
|
+
handler,
|
|
32
|
+
description: options?.description,
|
|
33
|
+
parameters: options?.parameters,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=Tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tool.js","sourceRoot":"","sources":["../../../src/core/Tool.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA6BH,gCAiBC;AArCD,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,UAAU,CACxB,IAAY,EACZ,OAA8C,EAC9C,OAGC;IAED,MAAM,EAAE,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,EAAE,CAAC;IAE7C,OAAO;QACL,EAAE;QACF,IAAI;QACJ,OAAO;QACP,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,UAAU,EAAE,OAAO,EAAE,UAAU;KAChC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transition between states in the route DSL
|
|
3
|
+
*/
|
|
4
|
+
import type { StateRef, TransitionSpec } from "../types/route";
|
|
5
|
+
import type { State } from "./State";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a transition from one state to another
|
|
8
|
+
*/
|
|
9
|
+
export declare class Transition<TContext = unknown> {
|
|
10
|
+
readonly source: StateRef;
|
|
11
|
+
readonly spec: TransitionSpec<TContext>;
|
|
12
|
+
readonly condition?: string | undefined;
|
|
13
|
+
private target?;
|
|
14
|
+
constructor(source: StateRef, spec: TransitionSpec<TContext>, condition?: string | undefined);
|
|
15
|
+
/**
|
|
16
|
+
* Set the target state for this transition
|
|
17
|
+
*/
|
|
18
|
+
setTarget(state: State<TContext>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get the target state
|
|
21
|
+
*/
|
|
22
|
+
getTarget(): State<TContext> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Check if this transition has a condition
|
|
25
|
+
*/
|
|
26
|
+
hasCondition(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get transition description for logging/debugging
|
|
29
|
+
*/
|
|
30
|
+
describe(): string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transition.d.ts","sourceRoot":"","sources":["../../../src/core/Transition.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;GAEG;AACH,qBAAa,UAAU,CAAC,QAAQ,GAAG,OAAO;aAItB,MAAM,EAAE,QAAQ;aAChB,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC;aAC9B,SAAS,CAAC,EAAE,MAAM;IALpC,OAAO,CAAC,MAAM,CAAC,CAAkB;gBAGf,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,EAC9B,SAAS,CAAC,EAAE,MAAM,YAAA;IAGpC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI;IAIvC;;OAEG;IACH,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,SAAS;IAIxC;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,QAAQ,IAAI,MAAM;CAsBnB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Transition between states in the route DSL
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Transition = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Represents a transition from one state to another
|
|
9
|
+
*/
|
|
10
|
+
class Transition {
|
|
11
|
+
constructor(source, spec, condition) {
|
|
12
|
+
this.source = source;
|
|
13
|
+
this.spec = spec;
|
|
14
|
+
this.condition = condition;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Set the target state for this transition
|
|
18
|
+
*/
|
|
19
|
+
setTarget(state) {
|
|
20
|
+
this.target = state;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the target state
|
|
24
|
+
*/
|
|
25
|
+
getTarget() {
|
|
26
|
+
return this.target;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if this transition has a condition
|
|
30
|
+
*/
|
|
31
|
+
hasCondition() {
|
|
32
|
+
return !!this.condition;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get transition description for logging/debugging
|
|
36
|
+
*/
|
|
37
|
+
describe() {
|
|
38
|
+
const parts = [];
|
|
39
|
+
if (this.spec.chatState) {
|
|
40
|
+
parts.push(`chat: "${this.spec.chatState}"`);
|
|
41
|
+
}
|
|
42
|
+
if (this.spec.toolState) {
|
|
43
|
+
parts.push(`tool: ${this.spec.toolState.name}`);
|
|
44
|
+
}
|
|
45
|
+
if (this.spec.state) {
|
|
46
|
+
if (typeof this.spec.state === "symbol") {
|
|
47
|
+
parts.push("state: END_ROUTE");
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
parts.push(`state: ${this.spec.state.id}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const transition = parts.join(", ");
|
|
54
|
+
const conditionPart = this.condition ? ` (when: ${this.condition})` : "";
|
|
55
|
+
return `${this.source.id} -> [${transition}]${conditionPart}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Transition = Transition;
|
|
59
|
+
//# sourceMappingURL=Transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transition.js","sourceRoot":"","sources":["../../../src/core/Transition.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAKH;;GAEG;AACH,MAAa,UAAU;IAGrB,YACkB,MAAgB,EAChB,IAA8B,EAC9B,SAAkB;QAFlB,WAAM,GAAN,MAAM,CAAU;QAChB,SAAI,GAAJ,IAAI,CAA0B;QAC9B,cAAS,GAAT,SAAS,CAAS;IACjC,CAAC;IAEJ;;OAEG;IACH,SAAS,CAAC,KAAsB;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAEzE,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,UAAU,IAAI,aAAa,EAAE,CAAC;IAChE,CAAC;CACF;AAvDD,gCAuDC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @falai/agent - Standalone AI Agent framework
|
|
3
|
+
*
|
|
4
|
+
* A strongly-typed, modular agent framework with route DSL and AI provider strategy
|
|
5
|
+
*/
|
|
6
|
+
export { Agent } from "./core/Agent";
|
|
7
|
+
export { Route } from "./core/Route";
|
|
8
|
+
export { State } from "./core/State";
|
|
9
|
+
export { Transition } from "./core/Transition";
|
|
10
|
+
export { Observation } from "./core/Observation";
|
|
11
|
+
export { defineTool } from "./core/Tool";
|
|
12
|
+
export { DomainRegistry } from "./core/DomainRegistry";
|
|
13
|
+
export { adaptEvent, createMessageEvent, createToolEvent } from "./core/Events";
|
|
14
|
+
export { PromptBuilder } from "./core/PromptBuilder";
|
|
15
|
+
export type { Customer, AgentInfo } from "./core/PromptBuilder";
|
|
16
|
+
export { BuiltInSection } from "./core/PromptBuilder";
|
|
17
|
+
export { GeminiProvider } from "./providers/GeminiProvider";
|
|
18
|
+
export type { GeminiProviderOptions } from "./providers/GeminiProvider";
|
|
19
|
+
export { OpenAIProvider } from "./providers/OpenAIProvider";
|
|
20
|
+
export type { OpenAIProviderOptions } from "./providers/OpenAIProvider";
|
|
21
|
+
export { OpenRouterProvider } from "./providers/OpenRouterProvider";
|
|
22
|
+
export type { OpenRouterProviderOptions } from "./providers/OpenRouterProvider";
|
|
23
|
+
export { END_ROUTE } from "./constants";
|
|
24
|
+
export type { AgentOptions, Term, Guideline, Capability, GuidelineMatch, } from "./types/agent";
|
|
25
|
+
export { CompositionMode } from "./types/agent";
|
|
26
|
+
export type { Event, EmittedEvent, MessageEventData, ToolEventData, StatusEventData, Participant, } from "./types/history";
|
|
27
|
+
export { EventKind, EventSource } from "./types/history";
|
|
28
|
+
export type { RouteRef, StateRef, RouteOptions, TransitionSpec, TransitionResult, } from "./types/route";
|
|
29
|
+
export type { ToolContext, ToolResult, ToolHandler, ToolRef, } from "./types/tool";
|
|
30
|
+
export type { AiProvider, GenerateMessageInput, GenerateMessageOutput, AgentStructuredResponse, ReasoningConfig, } from "./types/ai";
|
|
31
|
+
export type { PromptSection, ContextVariable, ContextVariableValue, } from "./types/prompt";
|
|
32
|
+
export { SectionStatus } from "./types/prompt";
|
|
33
|
+
export type { Observation as IObservation, ObservationOptions, } from "./types/observation";
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;A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QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,GACR,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,YAAY,EACV,WAAW,IAAI,YAAY,EAC3B,kBAAkB,GACnB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @falai/agent - Standalone AI Agent framework
|
|
4
|
+
*
|
|
5
|
+
* A strongly-typed, modular agent framework with route DSL and AI provider strategy
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SectionStatus = exports.EventSource = exports.EventKind = exports.CompositionMode = exports.END_ROUTE = exports.OpenRouterProvider = exports.OpenAIProvider = exports.GeminiProvider = exports.BuiltInSection = exports.PromptBuilder = exports.createToolEvent = exports.createMessageEvent = exports.adaptEvent = exports.DomainRegistry = exports.defineTool = exports.Observation = exports.Transition = exports.State = exports.Route = exports.Agent = void 0;
|
|
9
|
+
// Core
|
|
10
|
+
var Agent_1 = require("./core/Agent");
|
|
11
|
+
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return Agent_1.Agent; } });
|
|
12
|
+
var Route_1 = require("./core/Route");
|
|
13
|
+
Object.defineProperty(exports, "Route", { enumerable: true, get: function () { return Route_1.Route; } });
|
|
14
|
+
var State_1 = require("./core/State");
|
|
15
|
+
Object.defineProperty(exports, "State", { enumerable: true, get: function () { return State_1.State; } });
|
|
16
|
+
var Transition_1 = require("./core/Transition");
|
|
17
|
+
Object.defineProperty(exports, "Transition", { enumerable: true, get: function () { return Transition_1.Transition; } });
|
|
18
|
+
var Observation_1 = require("./core/Observation");
|
|
19
|
+
Object.defineProperty(exports, "Observation", { enumerable: true, get: function () { return Observation_1.Observation; } });
|
|
20
|
+
var Tool_1 = require("./core/Tool");
|
|
21
|
+
Object.defineProperty(exports, "defineTool", { enumerable: true, get: function () { return Tool_1.defineTool; } });
|
|
22
|
+
var DomainRegistry_1 = require("./core/DomainRegistry");
|
|
23
|
+
Object.defineProperty(exports, "DomainRegistry", { enumerable: true, get: function () { return DomainRegistry_1.DomainRegistry; } });
|
|
24
|
+
var Events_1 = require("./core/Events");
|
|
25
|
+
Object.defineProperty(exports, "adaptEvent", { enumerable: true, get: function () { return Events_1.adaptEvent; } });
|
|
26
|
+
Object.defineProperty(exports, "createMessageEvent", { enumerable: true, get: function () { return Events_1.createMessageEvent; } });
|
|
27
|
+
Object.defineProperty(exports, "createToolEvent", { enumerable: true, get: function () { return Events_1.createToolEvent; } });
|
|
28
|
+
var PromptBuilder_1 = require("./core/PromptBuilder");
|
|
29
|
+
Object.defineProperty(exports, "PromptBuilder", { enumerable: true, get: function () { return PromptBuilder_1.PromptBuilder; } });
|
|
30
|
+
var PromptBuilder_2 = require("./core/PromptBuilder");
|
|
31
|
+
Object.defineProperty(exports, "BuiltInSection", { enumerable: true, get: function () { return PromptBuilder_2.BuiltInSection; } });
|
|
32
|
+
// Providers
|
|
33
|
+
var GeminiProvider_1 = require("./providers/GeminiProvider");
|
|
34
|
+
Object.defineProperty(exports, "GeminiProvider", { enumerable: true, get: function () { return GeminiProvider_1.GeminiProvider; } });
|
|
35
|
+
var OpenAIProvider_1 = require("./providers/OpenAIProvider");
|
|
36
|
+
Object.defineProperty(exports, "OpenAIProvider", { enumerable: true, get: function () { return OpenAIProvider_1.OpenAIProvider; } });
|
|
37
|
+
var OpenRouterProvider_1 = require("./providers/OpenRouterProvider");
|
|
38
|
+
Object.defineProperty(exports, "OpenRouterProvider", { enumerable: true, get: function () { return OpenRouterProvider_1.OpenRouterProvider; } });
|
|
39
|
+
// Constants
|
|
40
|
+
var constants_1 = require("./constants");
|
|
41
|
+
Object.defineProperty(exports, "END_ROUTE", { enumerable: true, get: function () { return constants_1.END_ROUTE; } });
|
|
42
|
+
var agent_1 = require("./types/agent");
|
|
43
|
+
Object.defineProperty(exports, "CompositionMode", { enumerable: true, get: function () { return agent_1.CompositionMode; } });
|
|
44
|
+
var history_1 = require("./types/history");
|
|
45
|
+
Object.defineProperty(exports, "EventKind", { enumerable: true, get: function () { return history_1.EventKind; } });
|
|
46
|
+
Object.defineProperty(exports, "EventSource", { enumerable: true, get: function () { return history_1.EventSource; } });
|
|
47
|
+
var prompt_1 = require("./types/prompt");
|
|
48
|
+
Object.defineProperty(exports, "SectionStatus", { enumerable: true, get: function () { return prompt_1.SectionStatus; } });
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,OAAO;AACP,sCAAqC;AAA5B,8FAAA,KAAK,OAAA;AACd,sCAAqC;AAA5B,8FAAA,KAAK,OAAA;AACd,sCAAqC;AAA5B,8FAAA,KAAK,OAAA;AACd,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,kDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,oCAAyC;AAAhC,kGAAA,UAAU,OAAA;AACnB,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,wCAAgF;AAAvE,oGAAA,UAAU,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAAE,yGAAA,eAAe,OAAA;AACxD,sDAAqD;AAA5C,8GAAA,aAAa,OAAA;AAEtB,sDAAsD;AAA7C,+GAAA,cAAc,OAAA;AAEvB,YAAY;AACZ,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AAEvB,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AAEvB,qEAAoE;AAA3D,wHAAA,kBAAkB,OAAA;AAG3B,YAAY;AACZ,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAUlB,uCAAgD;AAAvC,wGAAA,eAAe,OAAA;AAUxB,2CAAyD;AAAhD,oGAAA,SAAS,OAAA;AAAE,sGAAA,WAAW,OAAA;AA8B/B,yCAA+C;AAAtC,uGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Gemini AI provider implementation with retry and backup models
|
|
3
|
+
*/
|
|
4
|
+
import type { GenerateContentConfig } from "@google/genai";
|
|
5
|
+
import type { AiProvider, GenerateMessageInput, GenerateMessageOutput } from "../types/ai";
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for Gemini provider
|
|
8
|
+
* Uses types from @google/genai package
|
|
9
|
+
*/
|
|
10
|
+
export interface GeminiProviderOptions {
|
|
11
|
+
/** Gemini API key */
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** Model to use (required) - e.g., "models/gemini-2.5-pro" */
|
|
14
|
+
model: string;
|
|
15
|
+
/** Backup models to try if primary fails (default: []) */
|
|
16
|
+
backupModels?: string[];
|
|
17
|
+
/** Default generation config - uses GenerateContentConfig from @google/genai */
|
|
18
|
+
config?: Partial<GenerateContentConfig>;
|
|
19
|
+
/** Retry configuration */
|
|
20
|
+
retryConfig?: {
|
|
21
|
+
timeout?: number;
|
|
22
|
+
retries?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gemini provider implementation with backup models and retry logic
|
|
27
|
+
*/
|
|
28
|
+
export declare class GeminiProvider implements AiProvider {
|
|
29
|
+
readonly name = "gemini";
|
|
30
|
+
private genAI;
|
|
31
|
+
private primaryModel;
|
|
32
|
+
private backupModels;
|
|
33
|
+
private config?;
|
|
34
|
+
private retryConfig;
|
|
35
|
+
constructor(options: GeminiProviderOptions);
|
|
36
|
+
generateMessage<TContext = unknown>(input: GenerateMessageInput<TContext>): Promise<GenerateMessageOutput>;
|
|
37
|
+
private generateWithBackup;
|
|
38
|
+
private generateWithModel;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=GeminiProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeminiProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/GeminiProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEV,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,aAAa,CAAC;AAQrB;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACxC,0BAA0B;IAC1B,WAAW,CAAC,EAAE;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AA8CD;;GAEG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,SAAgB,IAAI,YAAY;IAChC,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAAW;IAC/B,OAAO,CAAC,MAAM,CAAC,CAAiC;IAChD,OAAO,CAAC,WAAW,CAAuC;gBAE9C,OAAO,EAAE,qBAAqB;IAqBpC,eAAe,CAAC,QAAQ,GAAG,OAAO,EACtC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GACpC,OAAO,CAAC,qBAAqB,CAAC;YAInB,kBAAkB;YA2DlB,iBAAiB;CAqDhC"}
|