@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
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
149
+ PURPOSE. You are solely responsible for determining the appropriateness
150
+ of using or redistributing the Work and assume any risks associated with
151
+ Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Orca
2
+
3
+ **Orca (Orchestrated State Machine Language)** — an LLM-native code generation target that separates program topology (the state machine structure) from computation (individual action functions).
4
+
5
+ The core insight: LLMs generate flat transition tables reliably, and Orca's topology verifier ensures structural correctness that LLMs struggle to guarantee on their own.
6
+
7
+ ## Quick Start
8
+
9
+ ```bash
10
+ # Parse and verify a machine
11
+ npx tsx src/index.ts verify examples/simple-toggle.orca.md
12
+
13
+ # Compile to XState v5
14
+ npx tsx src/index.ts compile xstate examples/payment-processor.orca.md
15
+
16
+ # Compile to Mermaid diagram
17
+ npx tsx src/index.ts compile mermaid examples/text-adventure.orca.md
18
+
19
+ # Visualize (output Mermaid for rendering)
20
+ npx tsx src/index.ts visualize examples/simple-toggle.orca.md
21
+ ```
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install
27
+ npm run build
28
+ ```
29
+
30
+ ## CLI Skills
31
+
32
+ Orca's CLI exposes structured skills designed for LLM consumption:
33
+
34
+ ```bash
35
+ orca /verify-orca examples/payment-processor.orca.md
36
+ orca /compile-orca xstate examples/payment-processor.orca.md
37
+ orca /generate-actions examples/payment-processor.orca.md typescript
38
+ ```
39
+
40
+ ## Architecture
41
+
42
+ ```
43
+ Source (.orca.md) → Markdown Parser → AST → Verifier → Compiler → Output (XState/Mermaid)
44
+ ```
45
+
46
+ - **`src/parser/`** — Two-phase markdown parser (structural → semantic)
47
+ - **`src/verifier/`** — Topology checks (reachability, deadlock, completeness, determinism)
48
+ - **`src/compiler/`** — XState v5 and Mermaid compilation targets
49
+ - **`src/llm/`** — LLM provider abstraction (Anthropic, OpenAI, Grok, Ollama)
50
+ - **`src/generators/`** — Code generator registry for action implementations
51
+
52
+ ## LLM Integration
53
+
54
+ Orca uses its own LLM configuration, separate from the ambient context.
55
+
56
+ ### Setup
57
+
58
+ 1. **Copy the example env file:**
59
+ ```bash
60
+ cp .env.example .env
61
+ ```
62
+
63
+ 2. **Add your API key** to `.env`:
64
+ ```
65
+ ANTHROPIC_API_KEY=sk-ant-...
66
+ ```
67
+
68
+ 3. **Configure** in `orca.yaml`:
69
+ ```yaml
70
+ provider: anthropic
71
+ model: claude-sonnet-4-6
72
+ code_generator: typescript
73
+ ```
74
+
75
+ ### Supported Providers
76
+
77
+ | Provider | Environment Variable | Notes |
78
+ |----------|-------------------|-------|
79
+ | Anthropic | `ANTHROPIC_API_KEY` | Default |
80
+ | OpenAI | `OPENAI_API_KEY` | |
81
+ | xAI (Grok) | `XAI_API_KEY` | |
82
+ | Ollama | — | Set `base_url: http://localhost:11434` |
83
+
84
+ ### Authentication
85
+
86
+ Orca supports two authentication methods:
87
+
88
+ **1. API Key (simple)**
89
+ ```bash
90
+ cp .env.example .env
91
+ # Edit .env and add your API key
92
+ ```
93
+
94
+ **2. OAuth (for organization/team billing)**
95
+ ```bash
96
+ # Login with OAuth (supports Anthropic, MiniMax)
97
+ orca login --provider anthropic
98
+
99
+ # Check auth status
100
+ orca auth
101
+
102
+ # Logout
103
+ orca logout
104
+ ```
105
+
106
+ Credentials are stored in `~/.orca/auth_profiles.json`.
107
+
108
+ ### Generate Action Implementations
109
+
110
+ ```bash
111
+ # Without LLM (template-based, no API key needed)
112
+ orca actions examples/payment-processor.orca.md
113
+
114
+ # With LLM (requires API key)
115
+ orca /generate-actions --use-llm examples/payment-processor.orca.md typescript
116
+
117
+ # Output to directory (one file per action)
118
+ orca /generate-actions --use-llm examples/payment-processor.orca.md --output ./actions/
119
+
120
+ # Output to single file (all actions combined)
121
+ orca /generate-actions --use-llm examples/payment-processor.orca.md --output ./actions.ts
122
+ ```
123
+
124
+ See [docs/orca-proposal.md](docs/orca-proposal.md) for the full design specification.
125
+
126
+ ## License
127
+
128
+ Apache License 2.0 — see [LICENSE](LICENSE)
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export * from './store.js';
3
+ export * from './lock.js';
4
+ export * from './refresh.js';
5
+ export * from './providers/index.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export * from './store.js';
3
+ export * from './lock.js';
4
+ export * from './refresh.js';
5
+ export * from './providers/index.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function withFileLock<T>(resource: string, fn: () => Promise<T>): Promise<T>;
2
+ //# sourceMappingURL=lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/auth/lock.ts"],"names":[],"mappings":"AAkBA,wBAAsB,YAAY,CAAC,CAAC,EAClC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAiDZ"}
@@ -0,0 +1,59 @@
1
+ import { existsSync, mkdirSync, unlinkSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { homedir } from 'os';
4
+ import { createHash } from 'crypto';
5
+ const LOCK_DIR = join(homedir(), '.orca', 'locks');
6
+ const LOCK_TIMEOUT_MS = 30000; // 30 seconds
7
+ async function mkdirp(dir) {
8
+ if (!existsSync(dir)) {
9
+ mkdirSync(dir, { mode: 0o700, recursive: true });
10
+ }
11
+ }
12
+ export async function withFileLock(resource, fn) {
13
+ await mkdirp(LOCK_DIR);
14
+ // Create a unique lock file for this resource
15
+ const resourceHash = createHash('sha256').update(resource).digest('hex').slice(0, 16);
16
+ const lockFile = join(LOCK_DIR, `${resourceHash}.lock`);
17
+ const startTime = Date.now();
18
+ // Wait for lock
19
+ while (existsSync(lockFile)) {
20
+ if (Date.now() - startTime > LOCK_TIMEOUT_MS) {
21
+ throw new Error(`Timeout waiting for lock on ${resource}`);
22
+ }
23
+ await new Promise(resolve => setTimeout(resolve, 100));
24
+ }
25
+ // Acquire lock
26
+ const pid = process.pid.toString();
27
+ const lockContent = JSON.stringify({ pid, time: Date.now() });
28
+ // Use writeFileSync for atomic lock acquisition
29
+ // In a production system, you'd use a proper file locking mechanism
30
+ // This is a simplified version
31
+ try {
32
+ // Try to create the lock file exclusively
33
+ const { writeFileSync } = await import('fs');
34
+ writeFileSync(lockFile, lockContent, { flag: 'wx' });
35
+ }
36
+ catch (err) {
37
+ const error = err;
38
+ if (error.code === 'EEXIST') {
39
+ // Lock already exists, wait and retry
40
+ await new Promise(resolve => setTimeout(resolve, 100));
41
+ return withFileLock(resource, fn);
42
+ }
43
+ throw err;
44
+ }
45
+ // Execute the protected operation
46
+ try {
47
+ return await fn();
48
+ }
49
+ finally {
50
+ // Release lock
51
+ try {
52
+ unlinkSync(lockFile);
53
+ }
54
+ catch {
55
+ // Ignore cleanup errors
56
+ }
57
+ }
58
+ }
59
+ //# sourceMappingURL=lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/auth/lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACnD,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;AAM5C,KAAK,UAAU,MAAM,CAAC,GAAW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,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,GAAwB,CAAC;QACvC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,sCAAsC;YACtC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;YACvD,OAAO,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,kCAAkC;IAClC,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,eAAe;QACf,IAAI,CAAC;YACH,UAAU,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { OAuthProvider, TokenRefreshResult } from '../types.js';
2
+ export declare const anthropicOAuthProvider: OAuthProvider;
3
+ export declare function exchangeCodeForTokens(code: string, clientId: string, clientSecret: string, redirectUri: string): Promise<TokenRefreshResult>;
4
+ export declare function refreshAccessToken(refreshToken: string, clientId: string, clientSecret: string): Promise<TokenRefreshResult>;
5
+ export declare function buildAuthorizationUrl(clientId: string, redirectUri: string, state?: string): string;
6
+ export declare function promptForCode(): Promise<string>;
7
+ export declare function openBrowser(url: string): Promise<void>;
8
+ export declare function getDeviceCode(): Promise<{
9
+ device_code: string;
10
+ user_code: string;
11
+ verification_uri: string;
12
+ }>;
13
+ export declare function pollForToken(deviceCode: string): Promise<TokenRefreshResult>;
14
+ //# sourceMappingURL=anthropic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/auth/providers/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKhE,eAAO,MAAM,sBAAsB,EAAE,aAA2B,CAAC;AAWjE,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA2B7B;AAED,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,kBAAkB,CAAC,CA0B7B;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAYR;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAYrD;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB5D;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBnH;AAED,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmClF"}
@@ -0,0 +1,145 @@
1
+ import * as readline from 'readline';
2
+ const ANTHROPIC_AUTH_URL = 'https://api.anthropic.com/oauth/authorize';
3
+ const ANTHROPIC_TOKEN_URL = 'https://api.anthropic.com/oauth/token';
4
+ export const anthropicOAuthProvider = 'anthropic';
5
+ export async function exchangeCodeForTokens(code, clientId, clientSecret, redirectUri) {
6
+ const response = await fetch(ANTHROPIC_TOKEN_URL, {
7
+ method: 'POST',
8
+ headers: {
9
+ 'Content-Type': 'application/x-www-form-urlencoded',
10
+ },
11
+ body: new URLSearchParams({
12
+ grant_type: 'authorization_code',
13
+ code,
14
+ client_id: clientId,
15
+ client_secret: clientSecret,
16
+ redirect_uri: redirectUri,
17
+ }),
18
+ });
19
+ if (!response.ok) {
20
+ const error = await response.json();
21
+ throw new Error(`Token exchange failed: ${error.error_description ?? error.error}`);
22
+ }
23
+ const data = await response.json();
24
+ return {
25
+ access: data.access_token,
26
+ refresh: data.refresh_token,
27
+ expires: Date.now() + data.expires_in * 1000,
28
+ };
29
+ }
30
+ export async function refreshAccessToken(refreshToken, clientId, clientSecret) {
31
+ const response = await fetch(ANTHROPIC_TOKEN_URL, {
32
+ method: 'POST',
33
+ headers: {
34
+ 'Content-Type': 'application/x-www-form-urlencoded',
35
+ },
36
+ body: new URLSearchParams({
37
+ grant_type: 'refresh_token',
38
+ refresh_token: refreshToken,
39
+ client_id: clientId,
40
+ client_secret: clientSecret,
41
+ }),
42
+ });
43
+ if (!response.ok) {
44
+ const error = await response.json();
45
+ throw new Error(`Token refresh failed: ${error.error_description ?? error.error}`);
46
+ }
47
+ const data = await response.json();
48
+ return {
49
+ access: data.access_token,
50
+ refresh: data.refresh_token,
51
+ expires: Date.now() + data.expires_in * 1000,
52
+ };
53
+ }
54
+ export function buildAuthorizationUrl(clientId, redirectUri, state) {
55
+ const params = new URLSearchParams({
56
+ client_id: clientId,
57
+ response_type: 'code',
58
+ redirect_uri: redirectUri,
59
+ });
60
+ if (state) {
61
+ params.set('state', state);
62
+ }
63
+ return `${ANTHROPIC_AUTH_URL}?${params.toString()}`;
64
+ }
65
+ export async function promptForCode() {
66
+ const rl = readline.createInterface({
67
+ input: process.stdin,
68
+ output: process.stdout,
69
+ });
70
+ return new Promise((resolve) => {
71
+ rl.question('Enter the authorization code: ', (code) => {
72
+ rl.close();
73
+ resolve(code.trim());
74
+ });
75
+ });
76
+ }
77
+ export async function openBrowser(url) {
78
+ const { exec } = await import('child_process');
79
+ // Try different commands based on platform
80
+ const commands = ['open', 'xdg-open', 'start'];
81
+ for (const cmd of commands) {
82
+ try {
83
+ await new Promise((resolve, reject) => {
84
+ exec(`${cmd} "${url}"`, (err) => {
85
+ if (err)
86
+ reject(err);
87
+ else
88
+ resolve();
89
+ });
90
+ });
91
+ return;
92
+ }
93
+ catch {
94
+ // Try next command
95
+ }
96
+ }
97
+ console.log(`Please open this URL in your browser:\n${url}`);
98
+ }
99
+ export async function getDeviceCode() {
100
+ const response = await fetch('https://api.anthropic.com/oauth/device/code', {
101
+ method: 'POST',
102
+ headers: {
103
+ 'Content-Type': 'application/x-www-form-urlencoded',
104
+ },
105
+ body: new URLSearchParams({
106
+ client_id: 'orca-cli',
107
+ scope: 'api:read api:write',
108
+ }),
109
+ });
110
+ if (!response.ok) {
111
+ throw new Error(`Device code request failed: ${response.statusText}`);
112
+ }
113
+ return response.json();
114
+ }
115
+ export async function pollForToken(deviceCode) {
116
+ const startTime = Date.now();
117
+ const interval = 5000; // 5 seconds
118
+ while (Date.now() - startTime < 300000) { // 5 minute timeout
119
+ await new Promise(resolve => setTimeout(resolve, interval));
120
+ const response = await fetch(ANTHROPIC_TOKEN_URL, {
121
+ method: 'POST',
122
+ headers: {
123
+ 'Content-Type': 'application/x-www-form-urlencoded',
124
+ },
125
+ body: new URLSearchParams({
126
+ grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
127
+ device_code: deviceCode,
128
+ client_id: 'orca-cli',
129
+ }),
130
+ });
131
+ const data = await response.json();
132
+ if (data.access_token) {
133
+ return {
134
+ access: data.access_token,
135
+ refresh: data.refresh_token,
136
+ expires: Date.now() + data.expires_in * 1000,
137
+ };
138
+ }
139
+ if (data.error !== 'authorization_pending') {
140
+ throw new Error(`Device code polling failed: ${data.error_description ?? data.error}`);
141
+ }
142
+ }
143
+ throw new Error('Device code authorization timed out');
144
+ }
145
+ //# sourceMappingURL=anthropic.js.map
@@ -0,0 +1 @@
1
+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AC,KAAK,KAAK,uBAAuB,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { exchangeCodeForTokens as exchangeCodeForTokensAnthropic, refreshAccessToken as refreshAccessTokenAnthropic, buildAuthorizationUrl as buildAuthorizationUrlAnthropic, getDeviceCode, pollForToken, promptForCode, openBrowser, anthropicOAuthProvider, } from './anthropic.js';
2
+ export { exchangeCodeForTokens as exchangeCodeForTokensMiniMax, refreshAccessToken as refreshAccessTokenMiniMax, buildAuthorizationUrl as buildAuthorizationUrlMiniMax, minimaxOAuthProvider, } from './minimax.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,8BAA8B,EACvD,kBAAkB,IAAI,2BAA2B,EACjD,qBAAqB,IAAI,8BAA8B,EACvD,aAAa,EACb,YAAY,EACZ,aAAa,EACb,WAAW,EACX,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,IAAI,4BAA4B,EACrD,kBAAkB,IAAI,yBAAyB,EAC/C,qBAAqB,IAAI,4BAA4B,EACrD,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { exchangeCodeForTokens as exchangeCodeForTokensAnthropic, refreshAccessToken as refreshAccessTokenAnthropic, buildAuthorizationUrl as buildAuthorizationUrlAnthropic, getDeviceCode, pollForToken, promptForCode, openBrowser, anthropicOAuthProvider, } from './anthropic.js';
2
+ export { exchangeCodeForTokens as exchangeCodeForTokensMiniMax, refreshAccessToken as refreshAccessTokenMiniMax, buildAuthorizationUrl as buildAuthorizationUrlMiniMax, minimaxOAuthProvider, } from './minimax.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,8BAA8B,EACvD,kBAAkB,IAAI,2BAA2B,EACjD,qBAAqB,IAAI,8BAA8B,EACvD,aAAa,EACb,YAAY,EACZ,aAAa,EACb,WAAW,EACX,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,IAAI,4BAA4B,EACrD,kBAAkB,IAAI,yBAAyB,EAC/C,qBAAqB,IAAI,4BAA4B,EACrD,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { OAuthProvider, TokenRefreshResult } from '../types.js';
2
+ export declare const minimaxOAuthProvider: OAuthProvider;
3
+ export declare function exchangeCodeForTokens(code: string, clientId: string, clientSecret: string, redirectUri: string): Promise<TokenRefreshResult>;
4
+ export declare function refreshAccessToken(refreshToken: string, clientId: string, clientSecret: string): Promise<TokenRefreshResult>;
5
+ export declare function buildAuthorizationUrl(clientId: string, redirectUri: string, state?: string): string;
6
+ //# sourceMappingURL=minimax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minimax.d.ts","sourceRoot":"","sources":["../../../src/auth/providers/minimax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKhE,eAAO,MAAM,oBAAoB,EAAE,aAAyB,CAAC;AAW7D,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA2B7B;AAED,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,kBAAkB,CAAC,CA0B7B;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAaR"}