@defai.digital/iterate-domain 13.0.3
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 +214 -0
- package/dist/budget.d.ts +48 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +139 -0
- package/dist/budget.js.map +1 -0
- package/dist/controller.d.ts +44 -0
- package/dist/controller.d.ts.map +1 -0
- package/dist/controller.js +226 -0
- package/dist/controller.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/safety.d.ts +47 -0
- package/dist/safety.d.ts.map +1 -0
- package/dist/safety.js +171 -0
- package/dist/safety.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
- package/src/budget.ts +165 -0
- package/src/controller.ts +275 -0
- package/src/index.ts +54 -0
- package/src/safety.ts +198 -0
- package/src/types.ts +111 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterate Domain Internal Types
|
|
3
|
+
*
|
|
4
|
+
* Internal types for the iterate mode implementation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
IterateIntent,
|
|
9
|
+
IterateAction,
|
|
10
|
+
IterateBudget,
|
|
11
|
+
BudgetConsumed,
|
|
12
|
+
IterateBudgetStatus,
|
|
13
|
+
IterateState,
|
|
14
|
+
IterateSafetyConfig,
|
|
15
|
+
SafetyCheckResult,
|
|
16
|
+
IterateStartRequest,
|
|
17
|
+
IterateHandleResponse,
|
|
18
|
+
} from '@defai.digital/contracts';
|
|
19
|
+
|
|
20
|
+
// Re-export contract types for convenience
|
|
21
|
+
export type {
|
|
22
|
+
IterateIntent,
|
|
23
|
+
IterateAction,
|
|
24
|
+
IterateBudget,
|
|
25
|
+
BudgetConsumed,
|
|
26
|
+
IterateBudgetStatus,
|
|
27
|
+
IterateState,
|
|
28
|
+
IterateSafetyConfig,
|
|
29
|
+
SafetyCheckResult,
|
|
30
|
+
IterateStartRequest,
|
|
31
|
+
IterateHandleResponse,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Budget tracker interface
|
|
36
|
+
*/
|
|
37
|
+
export interface IBudgetTracker {
|
|
38
|
+
/**
|
|
39
|
+
* Start tracking budget
|
|
40
|
+
*/
|
|
41
|
+
start(): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Record an iteration
|
|
45
|
+
*/
|
|
46
|
+
recordIteration(tokens?: number): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Check budget status
|
|
50
|
+
*/
|
|
51
|
+
check(): IterateBudgetStatus;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check if budget is exceeded
|
|
55
|
+
*/
|
|
56
|
+
isExceeded(): boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get current consumption
|
|
60
|
+
*/
|
|
61
|
+
getConsumed(): BudgetConsumed;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get budget limits
|
|
65
|
+
*/
|
|
66
|
+
getBudget(): IterateBudget;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Safety guard interface
|
|
71
|
+
*/
|
|
72
|
+
export interface ISafetyGuard {
|
|
73
|
+
/**
|
|
74
|
+
* Check content for dangerous patterns
|
|
75
|
+
*/
|
|
76
|
+
checkContent(content: string): SafetyCheckResult;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Check if too many consecutive errors
|
|
80
|
+
*/
|
|
81
|
+
checkErrors(consecutiveErrors: number): SafetyCheckResult;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get safety configuration
|
|
85
|
+
*/
|
|
86
|
+
getConfig(): IterateSafetyConfig;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Iterate controller interface
|
|
91
|
+
*/
|
|
92
|
+
export interface IIterateController {
|
|
93
|
+
/**
|
|
94
|
+
* Start a new iterate session
|
|
95
|
+
*/
|
|
96
|
+
start(request: IterateStartRequest): IterateState;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Handle a response from the LLM
|
|
100
|
+
*/
|
|
101
|
+
handleResponse(
|
|
102
|
+
state: IterateState,
|
|
103
|
+
intent: IterateIntent,
|
|
104
|
+
content?: string
|
|
105
|
+
): IterateHandleResponse;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get auto-response for CONTINUE action
|
|
109
|
+
*/
|
|
110
|
+
getAutoResponse(intent: IterateIntent): string;
|
|
111
|
+
}
|