@grimoirelabs/core 0.1.0

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 (205) hide show
  1. package/dist/builders/expressions.d.ts +33 -0
  2. package/dist/builders/expressions.d.ts.map +1 -0
  3. package/dist/builders/expressions.js +57 -0
  4. package/dist/builders/expressions.js.map +1 -0
  5. package/dist/builders/index.d.ts +44 -0
  6. package/dist/builders/index.d.ts.map +1 -0
  7. package/dist/builders/index.js +32 -0
  8. package/dist/builders/index.js.map +1 -0
  9. package/dist/builders/spell-builder.d.ts +124 -0
  10. package/dist/builders/spell-builder.d.ts.map +1 -0
  11. package/dist/builders/spell-builder.js +299 -0
  12. package/dist/builders/spell-builder.js.map +1 -0
  13. package/dist/builders/step-builder.d.ts +212 -0
  14. package/dist/builders/step-builder.d.ts.map +1 -0
  15. package/dist/builders/step-builder.js +499 -0
  16. package/dist/builders/step-builder.js.map +1 -0
  17. package/dist/compiler/expression-parser.d.ts +14 -0
  18. package/dist/compiler/expression-parser.d.ts.map +1 -0
  19. package/dist/compiler/expression-parser.js +460 -0
  20. package/dist/compiler/expression-parser.js.map +1 -0
  21. package/dist/compiler/grimoire/ast.d.ts +450 -0
  22. package/dist/compiler/grimoire/ast.d.ts.map +1 -0
  23. package/dist/compiler/grimoire/ast.js +19 -0
  24. package/dist/compiler/grimoire/ast.js.map +1 -0
  25. package/dist/compiler/grimoire/errors.d.ts +65 -0
  26. package/dist/compiler/grimoire/errors.d.ts.map +1 -0
  27. package/dist/compiler/grimoire/errors.js +86 -0
  28. package/dist/compiler/grimoire/errors.js.map +1 -0
  29. package/dist/compiler/grimoire/index.d.ts +24 -0
  30. package/dist/compiler/grimoire/index.d.ts.map +1 -0
  31. package/dist/compiler/grimoire/index.js +63 -0
  32. package/dist/compiler/grimoire/index.js.map +1 -0
  33. package/dist/compiler/grimoire/parser.d.ts +135 -0
  34. package/dist/compiler/grimoire/parser.d.ts.map +1 -0
  35. package/dist/compiler/grimoire/parser.js +2148 -0
  36. package/dist/compiler/grimoire/parser.js.map +1 -0
  37. package/dist/compiler/grimoire/tokenizer.d.ts +59 -0
  38. package/dist/compiler/grimoire/tokenizer.d.ts.map +1 -0
  39. package/dist/compiler/grimoire/tokenizer.js +509 -0
  40. package/dist/compiler/grimoire/tokenizer.js.map +1 -0
  41. package/dist/compiler/grimoire/transformer.d.ts +71 -0
  42. package/dist/compiler/grimoire/transformer.d.ts.map +1 -0
  43. package/dist/compiler/grimoire/transformer.js +1011 -0
  44. package/dist/compiler/grimoire/transformer.js.map +1 -0
  45. package/dist/compiler/index.d.ts +45 -0
  46. package/dist/compiler/index.d.ts.map +1 -0
  47. package/dist/compiler/index.js +97 -0
  48. package/dist/compiler/index.js.map +1 -0
  49. package/dist/compiler/ir-generator.d.ts +16 -0
  50. package/dist/compiler/ir-generator.d.ts.map +1 -0
  51. package/dist/compiler/ir-generator.js +997 -0
  52. package/dist/compiler/ir-generator.js.map +1 -0
  53. package/dist/compiler/validator.d.ts +15 -0
  54. package/dist/compiler/validator.d.ts.map +1 -0
  55. package/dist/compiler/validator.js +401 -0
  56. package/dist/compiler/validator.js.map +1 -0
  57. package/dist/index.d.ts +16 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +17 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/runtime/circuit-breaker.d.ts +59 -0
  62. package/dist/runtime/circuit-breaker.d.ts.map +1 -0
  63. package/dist/runtime/circuit-breaker.js +155 -0
  64. package/dist/runtime/circuit-breaker.js.map +1 -0
  65. package/dist/runtime/context.d.ts +92 -0
  66. package/dist/runtime/context.d.ts.map +1 -0
  67. package/dist/runtime/context.js +219 -0
  68. package/dist/runtime/context.js.map +1 -0
  69. package/dist/runtime/error-classifier.d.ts +16 -0
  70. package/dist/runtime/error-classifier.d.ts.map +1 -0
  71. package/dist/runtime/error-classifier.js +38 -0
  72. package/dist/runtime/error-classifier.js.map +1 -0
  73. package/dist/runtime/expression-evaluator.d.ts +36 -0
  74. package/dist/runtime/expression-evaluator.d.ts.map +1 -0
  75. package/dist/runtime/expression-evaluator.js +391 -0
  76. package/dist/runtime/expression-evaluator.js.map +1 -0
  77. package/dist/runtime/index.d.ts +12 -0
  78. package/dist/runtime/index.d.ts.map +1 -0
  79. package/dist/runtime/index.js +11 -0
  80. package/dist/runtime/index.js.map +1 -0
  81. package/dist/runtime/interpreter.d.ts +59 -0
  82. package/dist/runtime/interpreter.d.ts.map +1 -0
  83. package/dist/runtime/interpreter.js +414 -0
  84. package/dist/runtime/interpreter.js.map +1 -0
  85. package/dist/runtime/skills/registry.d.ts +11 -0
  86. package/dist/runtime/skills/registry.d.ts.map +1 -0
  87. package/dist/runtime/skills/registry.js +73 -0
  88. package/dist/runtime/skills/registry.js.map +1 -0
  89. package/dist/runtime/sqlite-state-store.d.ts +28 -0
  90. package/dist/runtime/sqlite-state-store.d.ts.map +1 -0
  91. package/dist/runtime/sqlite-state-store.js +180 -0
  92. package/dist/runtime/sqlite-state-store.js.map +1 -0
  93. package/dist/runtime/state-store.d.ts +52 -0
  94. package/dist/runtime/state-store.d.ts.map +1 -0
  95. package/dist/runtime/state-store.js +32 -0
  96. package/dist/runtime/state-store.js.map +1 -0
  97. package/dist/runtime/steps/action.d.ts +17 -0
  98. package/dist/runtime/steps/action.d.ts.map +1 -0
  99. package/dist/runtime/steps/action.js +430 -0
  100. package/dist/runtime/steps/action.js.map +1 -0
  101. package/dist/runtime/steps/advisory.d.ts +28 -0
  102. package/dist/runtime/steps/advisory.d.ts.map +1 -0
  103. package/dist/runtime/steps/advisory.js +209 -0
  104. package/dist/runtime/steps/advisory.js.map +1 -0
  105. package/dist/runtime/steps/compute.d.ts +9 -0
  106. package/dist/runtime/steps/compute.d.ts.map +1 -0
  107. package/dist/runtime/steps/compute.js +74 -0
  108. package/dist/runtime/steps/compute.js.map +1 -0
  109. package/dist/runtime/steps/conditional.d.ts +14 -0
  110. package/dist/runtime/steps/conditional.d.ts.map +1 -0
  111. package/dist/runtime/steps/conditional.js +58 -0
  112. package/dist/runtime/steps/conditional.js.map +1 -0
  113. package/dist/runtime/steps/emit.d.ts +9 -0
  114. package/dist/runtime/steps/emit.d.ts.map +1 -0
  115. package/dist/runtime/steps/emit.js +70 -0
  116. package/dist/runtime/steps/emit.js.map +1 -0
  117. package/dist/runtime/steps/halt.d.ts +9 -0
  118. package/dist/runtime/steps/halt.d.ts.map +1 -0
  119. package/dist/runtime/steps/halt.js +19 -0
  120. package/dist/runtime/steps/halt.js.map +1 -0
  121. package/dist/runtime/steps/loop.d.ts +14 -0
  122. package/dist/runtime/steps/loop.d.ts.map +1 -0
  123. package/dist/runtime/steps/loop.js +109 -0
  124. package/dist/runtime/steps/loop.js.map +1 -0
  125. package/dist/runtime/steps/parallel.d.ts +9 -0
  126. package/dist/runtime/steps/parallel.d.ts.map +1 -0
  127. package/dist/runtime/steps/parallel.js +87 -0
  128. package/dist/runtime/steps/parallel.js.map +1 -0
  129. package/dist/runtime/steps/pipeline.d.ts +9 -0
  130. package/dist/runtime/steps/pipeline.d.ts.map +1 -0
  131. package/dist/runtime/steps/pipeline.js +125 -0
  132. package/dist/runtime/steps/pipeline.js.map +1 -0
  133. package/dist/runtime/steps/try.d.ts +13 -0
  134. package/dist/runtime/steps/try.d.ts.map +1 -0
  135. package/dist/runtime/steps/try.js +222 -0
  136. package/dist/runtime/steps/try.js.map +1 -0
  137. package/dist/runtime/steps/wait.d.ts +9 -0
  138. package/dist/runtime/steps/wait.d.ts.map +1 -0
  139. package/dist/runtime/steps/wait.js +38 -0
  140. package/dist/runtime/steps/wait.js.map +1 -0
  141. package/dist/types/actions.d.ts +162 -0
  142. package/dist/types/actions.d.ts.map +1 -0
  143. package/dist/types/actions.js +5 -0
  144. package/dist/types/actions.js.map +1 -0
  145. package/dist/types/execution.d.ts +276 -0
  146. package/dist/types/execution.d.ts.map +1 -0
  147. package/dist/types/execution.js +5 -0
  148. package/dist/types/execution.js.map +1 -0
  149. package/dist/types/expressions.d.ts +100 -0
  150. package/dist/types/expressions.d.ts.map +1 -0
  151. package/dist/types/expressions.js +48 -0
  152. package/dist/types/expressions.js.map +1 -0
  153. package/dist/types/index.d.ts +14 -0
  154. package/dist/types/index.d.ts.map +1 -0
  155. package/dist/types/index.js +5 -0
  156. package/dist/types/index.js.map +1 -0
  157. package/dist/types/ir.d.ts +187 -0
  158. package/dist/types/ir.d.ts.map +1 -0
  159. package/dist/types/ir.js +5 -0
  160. package/dist/types/ir.js.map +1 -0
  161. package/dist/types/policy.d.ts +123 -0
  162. package/dist/types/policy.d.ts.map +1 -0
  163. package/dist/types/policy.js +5 -0
  164. package/dist/types/policy.js.map +1 -0
  165. package/dist/types/primitives.d.ts +76 -0
  166. package/dist/types/primitives.d.ts.map +1 -0
  167. package/dist/types/primitives.js +10 -0
  168. package/dist/types/primitives.js.map +1 -0
  169. package/dist/types/steps.d.ts +226 -0
  170. package/dist/types/steps.d.ts.map +1 -0
  171. package/dist/types/steps.js +5 -0
  172. package/dist/types/steps.js.map +1 -0
  173. package/dist/venues/index.d.ts +6 -0
  174. package/dist/venues/index.d.ts.map +1 -0
  175. package/dist/venues/index.js +26 -0
  176. package/dist/venues/index.js.map +1 -0
  177. package/dist/venues/types.d.ts +40 -0
  178. package/dist/venues/types.d.ts.map +1 -0
  179. package/dist/venues/types.js +5 -0
  180. package/dist/venues/types.js.map +1 -0
  181. package/dist/wallet/executor.d.ts +109 -0
  182. package/dist/wallet/executor.d.ts.map +1 -0
  183. package/dist/wallet/executor.js +354 -0
  184. package/dist/wallet/executor.js.map +1 -0
  185. package/dist/wallet/index.d.ts +14 -0
  186. package/dist/wallet/index.d.ts.map +1 -0
  187. package/dist/wallet/index.js +13 -0
  188. package/dist/wallet/index.js.map +1 -0
  189. package/dist/wallet/keystore.d.ts +44 -0
  190. package/dist/wallet/keystore.d.ts.map +1 -0
  191. package/dist/wallet/keystore.js +296 -0
  192. package/dist/wallet/keystore.js.map +1 -0
  193. package/dist/wallet/provider.d.ts +111 -0
  194. package/dist/wallet/provider.d.ts.map +1 -0
  195. package/dist/wallet/provider.js +309 -0
  196. package/dist/wallet/provider.js.map +1 -0
  197. package/dist/wallet/tx-builder.d.ts +85 -0
  198. package/dist/wallet/tx-builder.d.ts.map +1 -0
  199. package/dist/wallet/tx-builder.js +290 -0
  200. package/dist/wallet/tx-builder.js.map +1 -0
  201. package/dist/wallet/types.d.ts +116 -0
  202. package/dist/wallet/types.d.ts.map +1 -0
  203. package/dist/wallet/types.js +86 -0
  204. package/dist/wallet/types.js.map +1 -0
  205. package/package.json +39 -0
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Action types for DeFi operations
3
+ */
4
+ import type { Expression } from "./expressions.js";
5
+ import type { Address, AssetId, BasisPoints, ChainId } from "./primitives.js";
6
+ /** Constraints for actions */
7
+ export interface ActionConstraints {
8
+ maxSlippageBps?: BasisPoints;
9
+ maxPriceImpactBps?: BasisPoints;
10
+ deadline?: number;
11
+ minOutput?: Expression;
12
+ maxInput?: Expression;
13
+ minLiquidity?: Expression;
14
+ requireQuote?: Expression;
15
+ requireSimulation?: Expression;
16
+ maxGas?: Expression;
17
+ }
18
+ export interface ActionConstraintsResolved {
19
+ maxSlippageBps?: BasisPoints;
20
+ maxPriceImpactBps?: BasisPoints;
21
+ deadline?: number;
22
+ minOutput?: bigint;
23
+ maxInput?: bigint;
24
+ minLiquidity?: bigint;
25
+ requireQuote?: boolean;
26
+ requireSimulation?: boolean;
27
+ maxGas?: bigint;
28
+ }
29
+ export type ActionAmount = Expression | bigint;
30
+ export type ActionChainId = Expression | ChainId;
31
+ type ActionBase = SwapAction | LendAction | WithdrawAction | BorrowAction | RepayAction | StakeAction | UnstakeAction | BridgeAction | ClaimAction | TransferAction | ApproveAction;
32
+ /** All action types */
33
+ export type Action = ActionBase & {
34
+ constraints?: ActionConstraintsResolved;
35
+ };
36
+ /** Action type discriminator */
37
+ export type ActionType = Action["type"];
38
+ /** Swap tokens */
39
+ export interface SwapAction {
40
+ type: "swap";
41
+ venue: string;
42
+ assetIn: AssetId;
43
+ assetOut: AssetId;
44
+ amount: ActionAmount;
45
+ mode: "exact_in" | "exact_out";
46
+ }
47
+ /** Lend/Supply to protocol */
48
+ export interface LendAction {
49
+ type: "lend";
50
+ venue: string;
51
+ asset: AssetId;
52
+ amount: ActionAmount | "max";
53
+ }
54
+ /** Withdraw from protocol */
55
+ export interface WithdrawAction {
56
+ type: "withdraw";
57
+ venue: string;
58
+ asset: AssetId;
59
+ amount: ActionAmount | "max";
60
+ }
61
+ /** Borrow from protocol */
62
+ export interface BorrowAction {
63
+ type: "borrow";
64
+ venue: string;
65
+ asset: AssetId;
66
+ amount: ActionAmount;
67
+ collateral?: AssetId;
68
+ }
69
+ /** Repay debt */
70
+ export interface RepayAction {
71
+ type: "repay";
72
+ venue: string;
73
+ asset: AssetId;
74
+ amount: ActionAmount | "max";
75
+ }
76
+ /** Stake tokens */
77
+ export interface StakeAction {
78
+ type: "stake";
79
+ venue: string;
80
+ asset: AssetId;
81
+ amount: ActionAmount;
82
+ }
83
+ /** Unstake tokens */
84
+ export interface UnstakeAction {
85
+ type: "unstake";
86
+ venue: string;
87
+ asset: AssetId;
88
+ amount: ActionAmount | "max";
89
+ }
90
+ /** Bridge to another chain */
91
+ export interface BridgeAction {
92
+ type: "bridge";
93
+ venue: string;
94
+ asset: AssetId;
95
+ amount: ActionAmount;
96
+ toChain: ActionChainId;
97
+ }
98
+ /** Claim rewards */
99
+ export interface ClaimAction {
100
+ type: "claim";
101
+ venue: string;
102
+ assets?: AssetId[];
103
+ }
104
+ /** Transfer tokens */
105
+ export interface TransferAction {
106
+ type: "transfer";
107
+ asset: AssetId;
108
+ amount: ActionAmount;
109
+ to: Address | Expression;
110
+ }
111
+ /** Approve token spending */
112
+ export interface ApproveAction {
113
+ type: "approve";
114
+ asset: AssetId;
115
+ amount: ActionAmount;
116
+ spender: Address;
117
+ }
118
+ /** Result of building calldata */
119
+ export interface CalldataBundle {
120
+ to: Address;
121
+ data: `0x${string}`;
122
+ value: bigint;
123
+ gasLimit?: bigint;
124
+ }
125
+ /** Result of simulating an action */
126
+ export interface SimulationResult {
127
+ success: boolean;
128
+ input: {
129
+ asset: AssetId;
130
+ amount: bigint;
131
+ };
132
+ output: {
133
+ asset: AssetId;
134
+ amount: bigint;
135
+ };
136
+ gasEstimate: bigint;
137
+ priceImpact?: BasisPoints;
138
+ error?: string;
139
+ }
140
+ /** Result of executing an action */
141
+ export interface ActionResult {
142
+ success: boolean;
143
+ action: Action;
144
+ venue: {
145
+ alias: string;
146
+ chain: ChainId;
147
+ address: Address;
148
+ };
149
+ txHash?: `0x${string}`;
150
+ gasUsed?: bigint;
151
+ input: {
152
+ asset: AssetId;
153
+ amount: bigint;
154
+ };
155
+ output: {
156
+ asset: AssetId;
157
+ amount: bigint;
158
+ };
159
+ error?: string;
160
+ }
161
+ export {};
162
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/types/actions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE9E,8BAA8B;AAC9B,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACxC,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AK,EAAE,OAAO,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Action types for DeFi operations
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/types/actions.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,276 @@
1
+ /**
2
+ * Execution context and result types
3
+ */
4
+ import type { Action, ActionConstraintsResolved } from "./actions.js";
5
+ import type { SpellIR } from "./ir.js";
6
+ import type { PolicySet } from "./policy.js";
7
+ import type { Address, ChainId, Timestamp, VenueAlias } from "./primitives.js";
8
+ /**
9
+ * Execution context - passed through during spell execution
10
+ */
11
+ export interface ExecutionContext {
12
+ spell: SpellIR;
13
+ policy?: PolicySet;
14
+ advisorTooling?: Record<string, {
15
+ skills: string[];
16
+ allowedTools: string[];
17
+ mcp?: string[];
18
+ }>;
19
+ runId: string;
20
+ startTime: Timestamp;
21
+ trigger: {
22
+ type: string;
23
+ [key: string]: unknown;
24
+ };
25
+ vault: Address;
26
+ chain: ChainId;
27
+ state: {
28
+ persistent: Map<string, unknown>;
29
+ ephemeral: Map<string, unknown>;
30
+ };
31
+ bindings: Map<string, unknown>;
32
+ callStack: CallFrame[];
33
+ executedSteps: string[];
34
+ metrics: ExecutionMetrics;
35
+ }
36
+ /** Call frame for tracking nested execution */
37
+ export interface CallFrame {
38
+ stepId: string;
39
+ startTime: Timestamp;
40
+ iteration?: number;
41
+ branch?: string;
42
+ }
43
+ /** Execution metrics */
44
+ export interface ExecutionMetrics {
45
+ stepsExecuted: number;
46
+ actionsExecuted: number;
47
+ gasUsed: bigint;
48
+ advisoryCalls: number;
49
+ errors: number;
50
+ retries: number;
51
+ }
52
+ /**
53
+ * Result of executing a spell
54
+ */
55
+ export interface ExecutionResult {
56
+ success: boolean;
57
+ runId: string;
58
+ startTime: Timestamp;
59
+ endTime: Timestamp;
60
+ duration: number;
61
+ error?: string;
62
+ metrics: ExecutionMetrics;
63
+ finalState: Record<string, unknown>;
64
+ ledgerEvents: LedgerEntry[];
65
+ }
66
+ /**
67
+ * Result of executing a single step
68
+ */
69
+ export interface StepResult {
70
+ success: boolean;
71
+ stepId: string;
72
+ output?: unknown;
73
+ error?: string;
74
+ halted?: boolean;
75
+ skipped?: boolean;
76
+ fallback?: boolean;
77
+ }
78
+ /** All ledger event types */
79
+ export type LedgerEvent = RunStartedEvent | RunCompletedEvent | RunFailedEvent | StepStartedEvent | StepCompletedEvent | StepFailedEvent | StepSkippedEvent | ActionSimulatedEvent | ActionSubmittedEvent | ActionConfirmedEvent | ActionRevertedEvent | PolicyCheckPassedEvent | PolicyCheckFailedEvent | GuardPassedEvent | GuardFailedEvent | StateReadEvent | StateWriteEvent | BindingSetEvent | AdvisoryStartedEvent | AdvisoryCompletedEvent | AdvisoryFailedEvent | AdvisoryRateLimitedEvent | EventEmittedEvent | ConstraintEvaluatedEvent | ErrorCaughtEvent | RetryAttemptedEvent | RetrySucceededEvent | RetryExhaustedEvent | CircuitBreakerTriggeredEvent | CircuitBreakerActionEvent;
80
+ interface RunStartedEvent {
81
+ type: "run_started";
82
+ runId: string;
83
+ spellId: string;
84
+ trigger: {
85
+ type: string;
86
+ };
87
+ }
88
+ interface RunCompletedEvent {
89
+ type: "run_completed";
90
+ runId: string;
91
+ success: boolean;
92
+ metrics: ExecutionMetrics;
93
+ }
94
+ interface RunFailedEvent {
95
+ type: "run_failed";
96
+ runId: string;
97
+ error: string;
98
+ }
99
+ interface StepStartedEvent {
100
+ type: "step_started";
101
+ stepId: string;
102
+ kind: string;
103
+ }
104
+ interface StepCompletedEvent {
105
+ type: "step_completed";
106
+ stepId: string;
107
+ result: unknown;
108
+ }
109
+ interface StepFailedEvent {
110
+ type: "step_failed";
111
+ stepId: string;
112
+ error: string;
113
+ line?: number;
114
+ column?: number;
115
+ }
116
+ interface StepSkippedEvent {
117
+ type: "step_skipped";
118
+ stepId: string;
119
+ reason: string;
120
+ }
121
+ interface ActionSimulatedEvent {
122
+ type: "action_simulated";
123
+ action: Action;
124
+ venue: VenueAlias;
125
+ result: {
126
+ success: boolean;
127
+ input: {
128
+ asset: string;
129
+ amount: string;
130
+ };
131
+ output: {
132
+ asset: string;
133
+ amount: string;
134
+ };
135
+ gasEstimate: string;
136
+ };
137
+ }
138
+ interface ActionSubmittedEvent {
139
+ type: "action_submitted";
140
+ action: Action;
141
+ txHash: string;
142
+ }
143
+ interface ActionConfirmedEvent {
144
+ type: "action_confirmed";
145
+ txHash: string;
146
+ gasUsed: string;
147
+ }
148
+ interface ActionRevertedEvent {
149
+ type: "action_reverted";
150
+ txHash: string;
151
+ reason: string;
152
+ }
153
+ interface PolicyCheckPassedEvent {
154
+ type: "policy_check_passed";
155
+ action: Action;
156
+ }
157
+ interface PolicyCheckFailedEvent {
158
+ type: "policy_check_failed";
159
+ action: Action;
160
+ violations: string[];
161
+ }
162
+ interface GuardPassedEvent {
163
+ type: "guard_passed";
164
+ guardId: string;
165
+ }
166
+ interface GuardFailedEvent {
167
+ type: "guard_failed";
168
+ guardId: string;
169
+ severity: string;
170
+ message: string;
171
+ }
172
+ interface StateReadEvent {
173
+ type: "state_read";
174
+ scope: string;
175
+ key: string;
176
+ value: unknown;
177
+ }
178
+ interface StateWriteEvent {
179
+ type: "state_write";
180
+ scope: string;
181
+ key: string;
182
+ oldValue: unknown;
183
+ newValue: unknown;
184
+ }
185
+ interface BindingSetEvent {
186
+ type: "binding_set";
187
+ name: string;
188
+ value: unknown;
189
+ }
190
+ interface AdvisoryStartedEvent {
191
+ type: "advisory_started";
192
+ advisor: string;
193
+ prompt: string;
194
+ skills?: string[];
195
+ allowedTools?: string[];
196
+ mcp?: string[];
197
+ schema?: AdvisorySchemaEvent;
198
+ }
199
+ interface AdvisoryCompletedEvent {
200
+ type: "advisory_completed";
201
+ advisor: string;
202
+ output: unknown;
203
+ }
204
+ interface AdvisoryFailedEvent {
205
+ type: "advisory_failed";
206
+ advisor: string;
207
+ error: string;
208
+ fallback: unknown;
209
+ }
210
+ interface AdvisoryRateLimitedEvent {
211
+ type: "advisory_rate_limited";
212
+ advisor: string;
213
+ }
214
+ interface EventEmittedEvent {
215
+ type: "event_emitted";
216
+ stepId: string;
217
+ event: string;
218
+ data: Record<string, unknown>;
219
+ }
220
+ interface ConstraintEvaluatedEvent {
221
+ type: "constraint_evaluated";
222
+ stepId: string;
223
+ constraints: ActionConstraintsResolved;
224
+ }
225
+ interface ErrorCaughtEvent {
226
+ type: "error_caught";
227
+ stepId: string;
228
+ errorType: string;
229
+ handler: string;
230
+ }
231
+ interface RetryAttemptedEvent {
232
+ type: "retry_attempted";
233
+ stepId: string;
234
+ attempt: number;
235
+ }
236
+ interface RetrySucceededEvent {
237
+ type: "retry_succeeded";
238
+ stepId: string;
239
+ attempt: number;
240
+ }
241
+ interface RetryExhaustedEvent {
242
+ type: "retry_exhausted";
243
+ stepId: string;
244
+ attempts: number;
245
+ }
246
+ interface CircuitBreakerTriggeredEvent {
247
+ type: "circuit_breaker_triggered";
248
+ breakerId: string;
249
+ trigger: unknown;
250
+ }
251
+ interface CircuitBreakerActionEvent {
252
+ type: "circuit_breaker_action";
253
+ breakerId: string;
254
+ action: string;
255
+ }
256
+ /** Ledger entry with metadata */
257
+ export interface LedgerEntry {
258
+ id: string;
259
+ timestamp: Timestamp;
260
+ runId: string;
261
+ spellId: string;
262
+ event: LedgerEvent;
263
+ }
264
+ export interface AdvisorySchemaEvent {
265
+ type: "boolean" | "number" | "enum" | "string" | "object" | "array";
266
+ values?: string[];
267
+ min?: number;
268
+ max?: number;
269
+ minLength?: number;
270
+ maxLength?: number;
271
+ pattern?: string;
272
+ fields?: Record<string, AdvisorySchemaEvent>;
273
+ items?: AdvisorySchemaEvent;
274
+ }
275
+ export {};
276
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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E,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,mBAAmB,CAAC;CAC7B"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Execution context and result types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Expression types for the Grimoire IR
3
+ */
4
+ /** Binary operators */
5
+ export type BinaryOp = "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "AND" | "OR";
6
+ /** Unary operators */
7
+ export type UnaryOp = "NOT" | "-" | "ABS";
8
+ /** Built-in function names */
9
+ export type BuiltinFn = "balance" | "price" | "get_apy" | "get_health_factor" | "get_position" | "get_debt" | "min" | "max" | "abs" | "sum" | "avg";
10
+ /** Expression IR node types */
11
+ export type Expression = LiteralExpr | ParamExpr | StateExpr | BindingExpr | ItemExpr | IndexExpr | BinaryExpr | UnaryExpr | TernaryExpr | CallExpr | ArrayAccessExpr | PropertyAccessExpr;
12
+ /** Literal value */
13
+ export interface LiteralExpr {
14
+ kind: "literal";
15
+ value: string | number | boolean | bigint | Record<string, unknown> | unknown[] | null;
16
+ type: "int" | "float" | "bool" | "string" | "address" | "json";
17
+ }
18
+ /** Parameter reference */
19
+ export interface ParamExpr {
20
+ kind: "param";
21
+ name: string;
22
+ }
23
+ /** State reference */
24
+ export interface StateExpr {
25
+ kind: "state";
26
+ scope: "persistent" | "ephemeral";
27
+ key: string;
28
+ }
29
+ /** Binding reference (from previous step) */
30
+ export interface BindingExpr {
31
+ kind: "binding";
32
+ name: string;
33
+ }
34
+ /** Current item in loop/pipeline */
35
+ export interface ItemExpr {
36
+ kind: "item";
37
+ }
38
+ /** Current index in loop/pipeline */
39
+ export interface IndexExpr {
40
+ kind: "index";
41
+ }
42
+ /** Binary operation */
43
+ export interface BinaryExpr {
44
+ kind: "binary";
45
+ op: BinaryOp;
46
+ left: Expression;
47
+ right: Expression;
48
+ }
49
+ /** Unary operation */
50
+ export interface UnaryExpr {
51
+ kind: "unary";
52
+ op: UnaryOp;
53
+ arg: Expression;
54
+ }
55
+ /** Ternary (conditional) operation */
56
+ export interface TernaryExpr {
57
+ kind: "ternary";
58
+ condition: Expression;
59
+ then: Expression;
60
+ else: Expression;
61
+ }
62
+ /** Function call */
63
+ export interface CallExpr {
64
+ kind: "call";
65
+ fn: BuiltinFn;
66
+ args: Expression[];
67
+ }
68
+ /** Array index access */
69
+ export interface ArrayAccessExpr {
70
+ kind: "array_access";
71
+ array: Expression;
72
+ index: Expression;
73
+ }
74
+ /** Object property access */
75
+ export interface PropertyAccessExpr {
76
+ kind: "property_access";
77
+ object: Expression;
78
+ property: string;
79
+ }
80
+ /**
81
+ * Helper to create literal expressions
82
+ */
83
+ export declare function literal(value: string | number | boolean | bigint | Record<string, unknown> | unknown[] | null, type?: LiteralExpr["type"]): LiteralExpr;
84
+ /**
85
+ * Helper to create param reference
86
+ */
87
+ export declare function param(name: string): ParamExpr;
88
+ /**
89
+ * Helper to create binding reference
90
+ */
91
+ export declare function binding(name: string): BindingExpr;
92
+ /**
93
+ * Helper to create binary expression
94
+ */
95
+ export declare function binary(op: BinaryOp, left: Expression, right: Expression): BinaryExpr;
96
+ /**
97
+ * Helper to create function call
98
+ */
99
+ export declare function call(fn: BuiltinFn, ...args: Expression[]): CallExpr;
100
+ //# sourceMappingURL=expressions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../../src/types/expressions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,uBAAuB;AACvB,MAAM,MAAM,QAAQ,GAChB,GA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AC,GACzB,WAAW,CAkBb;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAE7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAEjD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAEpF;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,QAAQ,CAEnE"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Expression types for the Grimoire IR
3
+ */
4
+ /**
5
+ * Helper to create literal expressions
6
+ */
7
+ export function literal(value, type) {
8
+ const inferredType = type ??
9
+ (typeof value === "string"
10
+ ? value.startsWith("0x")
11
+ ? "address"
12
+ : "string"
13
+ : typeof value === "boolean"
14
+ ? "bool"
15
+ : typeof value === "bigint"
16
+ ? "int"
17
+ : typeof value === "number"
18
+ ? Number.isInteger(value)
19
+ ? "int"
20
+ : "float"
21
+ : "json");
22
+ return { kind: "literal", value, type: inferredType };
23
+ }
24
+ /**
25
+ * Helper to create param reference
26
+ */
27
+ export function param(name) {
28
+ return { kind: "param", name };
29
+ }
30
+ /**
31
+ * Helper to create binding reference
32
+ */
33
+ export function binding(name) {
34
+ return { kind: "binding", name };
35
+ }
36
+ /**
37
+ * Helper to create binary expression
38
+ */
39
+ export function binary(op, left, right) {
40
+ return { kind: "binary", op, left, right };
41
+ }
42
+ /**
43
+ * Helper to create function call
44
+ */
45
+ export function call(fn, ...args) {
46
+ return { kind: "call", fn, args };
47
+ }
48
+ //# sourceMappingURL=expressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.js","sourceRoot":"","sources":["../../src/types/expressions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuIH;;GAEG;AACH,MAA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exports for @grimoirelabs/core
3
+ */
4
+ export type { ChainId, Address, AssetId, Timestamp, BasisPoints, HexString, Amount, VenueAlias, AssetDef, ParamDef, StateField, Trigger, WalletMode, } from "./primitives.js";
5
+ export { CHAINS } from "./primitives.js";
6
+ export type { SpellBuilder } from "../builders/spell-builder.js";
7
+ export type { StepBuilder, ComputeBuilder, ActionBuilder, ConditionalBuilder, LoopBuilder, ParallelBuilder, PipelineBuilder, TryBuilder, AdvisoryBuilder, WaitBuilder, EmitBuilder, HaltBuilder, } from "../builders/step-builder.js";
8
+ export type { Expression, BinaryOp, UnaryOp, BuiltinFn, LiteralExpr, ParamExpr, StateExpr, BindingExpr, ItemExpr, IndexExpr, BinaryExpr, UnaryExpr, TernaryExpr, CallExpr, ArrayAccessExpr, PropertyAccessExpr, } from "./expressions.js";
9
+ export type { Action, ActionType, SwapAction, LendAction, WithdrawAction, BorrowAction, RepayAction, StakeAction, UnstakeAction, BridgeAction, ClaimAction, TransferAction, ActionConstraints, CalldataBundle, SimulationResult, ActionResult, } from "./actions.js";
10
+ export type { Step, StepKind, OnFailure, ComputeStep, ActionStep, ConditionalStep, LoopStep, LoopType, ParallelStep, JoinStrategy, Branch, PipelineStep, PipelineStage, TryStep, CatchBlock, ErrorType, AdvisoryStep, AdvisoryOutputSchema, WaitStep, EmitStep, HaltStep, } from "./steps.js";
11
+ export type { SpellIR, SpellSource, AdvisorDef, SkillDef, Guard, AdvisoryGuard, GuardDef, StateSchema, CompilationResult, CompilationError, CompilationWarning, } from "./ir.js";
12
+ export type { PolicySet, ExposureLimit, CircuitBreaker, CircuitBreakerTrigger, PolicyCheckResult, ExposureResult, } from "./policy.js";
13
+ export type { ExecutionContext, CallFrame, ExecutionMetrics, ExecutionResult, StepResult, LedgerEvent, LedgerEntry, } from "./execution.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;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,QAAQ,EACR,KAAK,EACL,aAAa,EACb,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type exports for @grimoirelabs/core
3
+ */
4
+ export { CHAINS } from "./primitives.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmBH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC"}