@orcalang/orca-lang 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 (183) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +128 -0
  3. package/dist/auth/index.d.ts +6 -0
  4. package/dist/auth/index.d.ts.map +1 -0
  5. package/dist/auth/index.js +6 -0
  6. package/dist/auth/index.js.map +1 -0
  7. package/dist/auth/lock.d.ts +2 -0
  8. package/dist/auth/lock.d.ts.map +1 -0
  9. package/dist/auth/lock.js +59 -0
  10. package/dist/auth/lock.js.map +1 -0
  11. package/dist/auth/providers/anthropic.d.ts +14 -0
  12. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  13. package/dist/auth/providers/anthropic.js +145 -0
  14. package/dist/auth/providers/anthropic.js.map +1 -0
  15. package/dist/auth/providers/index.d.ts +3 -0
  16. package/dist/auth/providers/index.d.ts.map +1 -0
  17. package/dist/auth/providers/index.js +3 -0
  18. package/dist/auth/providers/index.js.map +1 -0
  19. package/dist/auth/providers/minimax.d.ts +6 -0
  20. package/dist/auth/providers/minimax.d.ts.map +1 -0
  21. package/dist/auth/providers/minimax.js +65 -0
  22. package/dist/auth/providers/minimax.js.map +1 -0
  23. package/dist/auth/refresh.d.ts +8 -0
  24. package/dist/auth/refresh.d.ts.map +1 -0
  25. package/dist/auth/refresh.js +104 -0
  26. package/dist/auth/refresh.js.map +1 -0
  27. package/dist/auth/store.d.ts +11 -0
  28. package/dist/auth/store.d.ts.map +1 -0
  29. package/dist/auth/store.js +63 -0
  30. package/dist/auth/store.js.map +1 -0
  31. package/dist/auth/types.d.ts +51 -0
  32. package/dist/auth/types.d.ts.map +1 -0
  33. package/dist/auth/types.js +2 -0
  34. package/dist/auth/types.js.map +1 -0
  35. package/dist/compiler/mermaid.d.ts +3 -0
  36. package/dist/compiler/mermaid.d.ts.map +1 -0
  37. package/dist/compiler/mermaid.js +86 -0
  38. package/dist/compiler/mermaid.js.map +1 -0
  39. package/dist/compiler/xstate.d.ts +15 -0
  40. package/dist/compiler/xstate.d.ts.map +1 -0
  41. package/dist/compiler/xstate.js +542 -0
  42. package/dist/compiler/xstate.js.map +1 -0
  43. package/dist/config/index.d.ts +3 -0
  44. package/dist/config/index.d.ts.map +1 -0
  45. package/dist/config/index.js +3 -0
  46. package/dist/config/index.js.map +1 -0
  47. package/dist/config/loader.d.ts +4 -0
  48. package/dist/config/loader.d.ts.map +1 -0
  49. package/dist/config/loader.js +109 -0
  50. package/dist/config/loader.js.map +1 -0
  51. package/dist/config/types.d.ts +13 -0
  52. package/dist/config/types.d.ts.map +1 -0
  53. package/dist/config/types.js +8 -0
  54. package/dist/config/types.js.map +1 -0
  55. package/dist/generators/index.d.ts +5 -0
  56. package/dist/generators/index.d.ts.map +1 -0
  57. package/dist/generators/index.js +5 -0
  58. package/dist/generators/index.js.map +1 -0
  59. package/dist/generators/registry.d.ts +12 -0
  60. package/dist/generators/registry.d.ts.map +1 -0
  61. package/dist/generators/registry.js +15 -0
  62. package/dist/generators/registry.js.map +1 -0
  63. package/dist/generators/typescript.d.ts +9 -0
  64. package/dist/generators/typescript.d.ts.map +1 -0
  65. package/dist/generators/typescript.js +55 -0
  66. package/dist/generators/typescript.js.map +1 -0
  67. package/dist/index.d.ts +10 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +630 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/llm/anthropic.d.ts +14 -0
  72. package/dist/llm/anthropic.d.ts.map +1 -0
  73. package/dist/llm/anthropic.js +87 -0
  74. package/dist/llm/anthropic.js.map +1 -0
  75. package/dist/llm/grok.d.ts +13 -0
  76. package/dist/llm/grok.d.ts.map +1 -0
  77. package/dist/llm/grok.js +60 -0
  78. package/dist/llm/grok.js.map +1 -0
  79. package/dist/llm/index.d.ts +11 -0
  80. package/dist/llm/index.d.ts.map +1 -0
  81. package/dist/llm/index.js +23 -0
  82. package/dist/llm/index.js.map +1 -0
  83. package/dist/llm/ollama.d.ts +11 -0
  84. package/dist/llm/ollama.d.ts.map +1 -0
  85. package/dist/llm/ollama.js +51 -0
  86. package/dist/llm/ollama.js.map +1 -0
  87. package/dist/llm/openai.d.ts +13 -0
  88. package/dist/llm/openai.d.ts.map +1 -0
  89. package/dist/llm/openai.js +61 -0
  90. package/dist/llm/openai.js.map +1 -0
  91. package/dist/llm/provider.d.ts +32 -0
  92. package/dist/llm/provider.d.ts.map +1 -0
  93. package/dist/llm/provider.js +2 -0
  94. package/dist/llm/provider.js.map +1 -0
  95. package/dist/parser/ast-to-markdown.d.ts +3 -0
  96. package/dist/parser/ast-to-markdown.d.ts.map +1 -0
  97. package/dist/parser/ast-to-markdown.js +209 -0
  98. package/dist/parser/ast-to-markdown.js.map +1 -0
  99. package/dist/parser/ast.d.ts +183 -0
  100. package/dist/parser/ast.d.ts.map +1 -0
  101. package/dist/parser/ast.js +3 -0
  102. package/dist/parser/ast.js.map +1 -0
  103. package/dist/parser/markdown-parser.d.ts +8 -0
  104. package/dist/parser/markdown-parser.d.ts.map +1 -0
  105. package/dist/parser/markdown-parser.js +838 -0
  106. package/dist/parser/markdown-parser.js.map +1 -0
  107. package/dist/runtime/effects.d.ts +17 -0
  108. package/dist/runtime/effects.d.ts.map +1 -0
  109. package/dist/runtime/effects.js +28 -0
  110. package/dist/runtime/effects.js.map +1 -0
  111. package/dist/runtime/machine.d.ts +8 -0
  112. package/dist/runtime/machine.d.ts.map +1 -0
  113. package/dist/runtime/machine.js +158 -0
  114. package/dist/runtime/machine.js.map +1 -0
  115. package/dist/runtime/types.d.ts +37 -0
  116. package/dist/runtime/types.d.ts.map +1 -0
  117. package/dist/runtime/types.js +3 -0
  118. package/dist/runtime/types.js.map +1 -0
  119. package/dist/skills.d.ts +114 -0
  120. package/dist/skills.d.ts.map +1 -0
  121. package/dist/skills.js +1103 -0
  122. package/dist/skills.js.map +1 -0
  123. package/dist/tools.d.ts +18 -0
  124. package/dist/tools.d.ts.map +1 -0
  125. package/dist/tools.js +124 -0
  126. package/dist/tools.js.map +1 -0
  127. package/dist/verifier/completeness.d.ts +4 -0
  128. package/dist/verifier/completeness.d.ts.map +1 -0
  129. package/dist/verifier/completeness.js +82 -0
  130. package/dist/verifier/completeness.js.map +1 -0
  131. package/dist/verifier/determinism.d.ts +17 -0
  132. package/dist/verifier/determinism.d.ts.map +1 -0
  133. package/dist/verifier/determinism.js +301 -0
  134. package/dist/verifier/determinism.js.map +1 -0
  135. package/dist/verifier/properties.d.ts +6 -0
  136. package/dist/verifier/properties.d.ts.map +1 -0
  137. package/dist/verifier/properties.js +404 -0
  138. package/dist/verifier/properties.js.map +1 -0
  139. package/dist/verifier/structural.d.ts +50 -0
  140. package/dist/verifier/structural.d.ts.map +1 -0
  141. package/dist/verifier/structural.js +692 -0
  142. package/dist/verifier/structural.js.map +1 -0
  143. package/dist/verifier/types.d.ts +40 -0
  144. package/dist/verifier/types.d.ts.map +1 -0
  145. package/dist/verifier/types.js +2 -0
  146. package/dist/verifier/types.js.map +1 -0
  147. package/package.json +49 -0
  148. package/src/auth/index.ts +5 -0
  149. package/src/auth/lock.ts +71 -0
  150. package/src/auth/providers/anthropic.ts +192 -0
  151. package/src/auth/providers/index.ts +17 -0
  152. package/src/auth/providers/minimax.ts +100 -0
  153. package/src/auth/refresh.ts +138 -0
  154. package/src/auth/store.ts +75 -0
  155. package/src/auth/types.ts +62 -0
  156. package/src/compiler/mermaid.ts +109 -0
  157. package/src/compiler/xstate.ts +615 -0
  158. package/src/config/index.ts +2 -0
  159. package/src/config/loader.ts +122 -0
  160. package/src/config/types.ts +21 -0
  161. package/src/generators/index.ts +6 -0
  162. package/src/generators/registry.ts +27 -0
  163. package/src/generators/typescript.ts +67 -0
  164. package/src/index.ts +671 -0
  165. package/src/llm/anthropic.ts +102 -0
  166. package/src/llm/grok.ts +73 -0
  167. package/src/llm/index.ts +29 -0
  168. package/src/llm/ollama.ts +62 -0
  169. package/src/llm/openai.ts +74 -0
  170. package/src/llm/provider.ts +35 -0
  171. package/src/parser/ast-to-markdown.ts +220 -0
  172. package/src/parser/ast.ts +236 -0
  173. package/src/parser/markdown-parser.ts +844 -0
  174. package/src/runtime/effects.ts +48 -0
  175. package/src/runtime/machine.ts +201 -0
  176. package/src/runtime/types.ts +44 -0
  177. package/src/skills.ts +1339 -0
  178. package/src/tools.ts +144 -0
  179. package/src/verifier/completeness.ts +89 -0
  180. package/src/verifier/determinism.ts +328 -0
  181. package/src/verifier/properties.ts +507 -0
  182. package/src/verifier/structural.ts +803 -0
  183. package/src/verifier/types.ts +45 -0
@@ -0,0 +1,236 @@
1
+ // Orca AST Type Definitions
2
+
3
+ export interface Position {
4
+ line: number;
5
+ column: number;
6
+ offset: number;
7
+ }
8
+
9
+ export interface Token {
10
+ type: TokenType;
11
+ value: string;
12
+ pos: Position;
13
+ }
14
+
15
+ export type TokenType =
16
+ | 'IDENT'
17
+ | 'STRING'
18
+ | 'NUMBER'
19
+ | 'LBRACE'
20
+ | 'RBRACE'
21
+ | 'LBRACKET'
22
+ | 'RBRACKET'
23
+ | 'LPAREN'
24
+ | 'RPAREN'
25
+ | 'PLUS'
26
+ | 'ARROW'
27
+ | 'COLON'
28
+ | 'COMMA'
29
+ | 'PIPE'
30
+ | 'QUESTION'
31
+ | 'EQ'
32
+ | 'NE'
33
+ | 'LT'
34
+ | 'GT'
35
+ | 'LE'
36
+ | 'GE'
37
+ | 'AND'
38
+ | 'OR'
39
+ | 'NOT'
40
+ | 'DOT'
41
+ | 'ON_ENTRY'
42
+ | 'ON_EXIT'
43
+ | 'TIMEOUT'
44
+ | 'IGNORE'
45
+ | 'MACHINE'
46
+ | 'CONTEXT'
47
+ | 'EVENTS'
48
+ | 'STATE'
49
+ | 'TRANSITIONS'
50
+ | 'GUARDS'
51
+ | 'ACTIONS'
52
+ | 'INITIAL'
53
+ | 'FINAL'
54
+ | 'DESCRIPTION'
55
+ | 'CONTAINS'
56
+ | 'PARALLEL'
57
+ | 'REGION'
58
+ | 'ON_DONE'
59
+ | 'PROPERTIES'
60
+ | 'EOF'
61
+ | 'UNKNOWN';
62
+
63
+ export interface ContextField {
64
+ name: string;
65
+ type: Type;
66
+ defaultValue?: string;
67
+ }
68
+
69
+ export type Type =
70
+ | { kind: 'string' }
71
+ | { kind: 'int' }
72
+ | { kind: 'decimal' }
73
+ | { kind: 'bool' }
74
+ | { kind: 'array'; elementType: string }
75
+ | { kind: 'map'; keyType: string; valueType: string }
76
+ | { kind: 'optional'; innerType: string }
77
+ | { kind: 'custom'; name: string };
78
+
79
+ export interface EventDef {
80
+ name: string;
81
+ payload?: ContextField[];
82
+ }
83
+
84
+ export interface RegionDef {
85
+ name: string;
86
+ states: StateDef[];
87
+ }
88
+
89
+ export type SyncStrategy = 'all-final' | 'any-final' | 'custom';
90
+
91
+ export interface ParallelDef {
92
+ regions: RegionDef[];
93
+ sync?: SyncStrategy; // default: 'all-final'
94
+ }
95
+
96
+ export interface InvokeDef {
97
+ machine: string; // Name of machine to invoke
98
+ input?: Record<string, string>; // Optional: ctx.field -> child param mapping
99
+ onDone?: string; // Event to emit when child completes
100
+ onError?: string; // Event to emit when child errors
101
+ }
102
+
103
+ export interface StateDef {
104
+ name: string;
105
+ description?: string;
106
+ isInitial: boolean;
107
+ isFinal: boolean;
108
+ onEntry?: string;
109
+ onExit?: string;
110
+ onDone?: string; // target state when parallel sync completes
111
+ timeout?: {
112
+ duration: string;
113
+ target: string;
114
+ };
115
+ invoke?: InvokeDef; // machine invocation (mutually exclusive with contains/parallel)
116
+ contains?: StateDef[];
117
+ parallel?: ParallelDef; // mutually exclusive with contains
118
+ parent?: string; // Parent state name for hierarchical states
119
+ transitions?: Transition[];
120
+ ignoredEvents?: string[];
121
+ }
122
+
123
+ export interface Transition {
124
+ source: string;
125
+ event: string;
126
+ guard?: GuardRef;
127
+ target: string;
128
+ action?: string;
129
+ }
130
+
131
+ export interface GuardRef {
132
+ name: string;
133
+ negated: boolean;
134
+ }
135
+
136
+ export interface GuardDef {
137
+ name: string;
138
+ expression: GuardExpression;
139
+ }
140
+
141
+ export type GuardExpression =
142
+ | { kind: 'true' }
143
+ | { kind: 'false' }
144
+ | { kind: 'not'; expr: GuardExpression }
145
+ | { kind: 'and'; left: GuardExpression; right: GuardExpression }
146
+ | { kind: 'or'; left: GuardExpression; right: GuardExpression }
147
+ | { kind: 'compare'; op: ComparisonOp; left: VariableRef; right: ValueRef }
148
+ | { kind: 'nullcheck'; expr: VariableRef; isNull: boolean };
149
+
150
+ export type ComparisonOp = 'eq' | 'ne' | 'lt' | 'gt' | 'le' | 'ge';
151
+
152
+ export interface VariableRef {
153
+ kind: 'variable';
154
+ path: string[];
155
+ }
156
+
157
+ export interface ValueRef {
158
+ kind: 'value';
159
+ type: 'string' | 'number' | 'boolean' | 'null';
160
+ value: string | number | boolean | null;
161
+ }
162
+
163
+ export interface ActionSignature {
164
+ name: string;
165
+ parameters: string[];
166
+ returnType: string;
167
+ hasEffect: boolean;
168
+ effectType?: string;
169
+ }
170
+
171
+ export interface EffectDef {
172
+ name: string;
173
+ input: string; // free-form description of input shape
174
+ output: string; // free-form description of output shape
175
+ }
176
+
177
+ // Property types for bounded model checking
178
+
179
+ export interface ReachabilityProperty {
180
+ kind: 'reachable' | 'unreachable';
181
+ from: string;
182
+ to: string;
183
+ }
184
+
185
+ export interface PassesThroughProperty {
186
+ kind: 'passes_through';
187
+ from: string;
188
+ to: string;
189
+ through: string;
190
+ }
191
+
192
+ export interface LiveProperty {
193
+ kind: 'live';
194
+ }
195
+
196
+ export interface RespondsProperty {
197
+ kind: 'responds';
198
+ from: string;
199
+ to: string;
200
+ within: number;
201
+ }
202
+
203
+ export interface InvariantProperty {
204
+ kind: 'invariant';
205
+ expression: GuardExpression;
206
+ inState?: string;
207
+ }
208
+
209
+ export type Property =
210
+ | ReachabilityProperty
211
+ | PassesThroughProperty
212
+ | LiveProperty
213
+ | RespondsProperty
214
+ | InvariantProperty;
215
+
216
+ export interface MachineDef {
217
+ name: string;
218
+ context: ContextField[];
219
+ events: EventDef[];
220
+ states: StateDef[];
221
+ transitions: Transition[];
222
+ guards: GuardDef[];
223
+ actions: ActionSignature[];
224
+ effects?: EffectDef[]; // declared in ## effects section; undefined if section absent
225
+ properties?: Property[];
226
+ }
227
+
228
+ // Multi-machine file (for machine invocation)
229
+ export interface OrcaFile {
230
+ machines: MachineDef[];
231
+ }
232
+
233
+ export interface ParseResult {
234
+ file: OrcaFile;
235
+ tokens: Token[];
236
+ }