@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.
- package/LICENSE +176 -0
- package/README.md +128 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/lock.d.ts +2 -0
- package/dist/auth/lock.d.ts.map +1 -0
- package/dist/auth/lock.js +59 -0
- package/dist/auth/lock.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +14 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +145 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/index.d.ts +3 -0
- package/dist/auth/providers/index.d.ts.map +1 -0
- package/dist/auth/providers/index.js +3 -0
- package/dist/auth/providers/index.js.map +1 -0
- package/dist/auth/providers/minimax.d.ts +6 -0
- package/dist/auth/providers/minimax.d.ts.map +1 -0
- package/dist/auth/providers/minimax.js +65 -0
- package/dist/auth/providers/minimax.js.map +1 -0
- package/dist/auth/refresh.d.ts +8 -0
- package/dist/auth/refresh.d.ts.map +1 -0
- package/dist/auth/refresh.js +104 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/auth/store.d.ts +11 -0
- package/dist/auth/store.d.ts.map +1 -0
- package/dist/auth/store.js +63 -0
- package/dist/auth/store.js.map +1 -0
- package/dist/auth/types.d.ts +51 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/compiler/mermaid.d.ts +3 -0
- package/dist/compiler/mermaid.d.ts.map +1 -0
- package/dist/compiler/mermaid.js +86 -0
- package/dist/compiler/mermaid.js.map +1 -0
- package/dist/compiler/xstate.d.ts +15 -0
- package/dist/compiler/xstate.d.ts.map +1 -0
- package/dist/compiler/xstate.js +542 -0
- package/dist/compiler/xstate.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +4 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +109 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +13 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +8 -0
- package/dist/config/types.js.map +1 -0
- package/dist/generators/index.d.ts +5 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +5 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/registry.d.ts +12 -0
- package/dist/generators/registry.d.ts.map +1 -0
- package/dist/generators/registry.js +15 -0
- package/dist/generators/registry.js.map +1 -0
- package/dist/generators/typescript.d.ts +9 -0
- package/dist/generators/typescript.d.ts.map +1 -0
- package/dist/generators/typescript.js +55 -0
- package/dist/generators/typescript.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +630 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/anthropic.d.ts +14 -0
- package/dist/llm/anthropic.d.ts.map +1 -0
- package/dist/llm/anthropic.js +87 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/grok.d.ts +13 -0
- package/dist/llm/grok.d.ts.map +1 -0
- package/dist/llm/grok.js +60 -0
- package/dist/llm/grok.js.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +23 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/ollama.d.ts +11 -0
- package/dist/llm/ollama.d.ts.map +1 -0
- package/dist/llm/ollama.js +51 -0
- package/dist/llm/ollama.js.map +1 -0
- package/dist/llm/openai.d.ts +13 -0
- package/dist/llm/openai.d.ts.map +1 -0
- package/dist/llm/openai.js +61 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/provider.d.ts +32 -0
- package/dist/llm/provider.d.ts.map +1 -0
- package/dist/llm/provider.js +2 -0
- package/dist/llm/provider.js.map +1 -0
- package/dist/parser/ast-to-markdown.d.ts +3 -0
- package/dist/parser/ast-to-markdown.d.ts.map +1 -0
- package/dist/parser/ast-to-markdown.js +209 -0
- package/dist/parser/ast-to-markdown.js.map +1 -0
- package/dist/parser/ast.d.ts +183 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +3 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/markdown-parser.d.ts +8 -0
- package/dist/parser/markdown-parser.d.ts.map +1 -0
- package/dist/parser/markdown-parser.js +838 -0
- package/dist/parser/markdown-parser.js.map +1 -0
- package/dist/runtime/effects.d.ts +17 -0
- package/dist/runtime/effects.d.ts.map +1 -0
- package/dist/runtime/effects.js +28 -0
- package/dist/runtime/effects.js.map +1 -0
- package/dist/runtime/machine.d.ts +8 -0
- package/dist/runtime/machine.d.ts.map +1 -0
- package/dist/runtime/machine.js +158 -0
- package/dist/runtime/machine.js.map +1 -0
- package/dist/runtime/types.d.ts +37 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +3 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/skills.d.ts +114 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +1103 -0
- package/dist/skills.js.map +1 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +124 -0
- package/dist/tools.js.map +1 -0
- package/dist/verifier/completeness.d.ts +4 -0
- package/dist/verifier/completeness.d.ts.map +1 -0
- package/dist/verifier/completeness.js +82 -0
- package/dist/verifier/completeness.js.map +1 -0
- package/dist/verifier/determinism.d.ts +17 -0
- package/dist/verifier/determinism.d.ts.map +1 -0
- package/dist/verifier/determinism.js +301 -0
- package/dist/verifier/determinism.js.map +1 -0
- package/dist/verifier/properties.d.ts +6 -0
- package/dist/verifier/properties.d.ts.map +1 -0
- package/dist/verifier/properties.js +404 -0
- package/dist/verifier/properties.js.map +1 -0
- package/dist/verifier/structural.d.ts +50 -0
- package/dist/verifier/structural.d.ts.map +1 -0
- package/dist/verifier/structural.js +692 -0
- package/dist/verifier/structural.js.map +1 -0
- package/dist/verifier/types.d.ts +40 -0
- package/dist/verifier/types.d.ts.map +1 -0
- package/dist/verifier/types.js +2 -0
- package/dist/verifier/types.js.map +1 -0
- package/package.json +49 -0
- package/src/auth/index.ts +5 -0
- package/src/auth/lock.ts +71 -0
- package/src/auth/providers/anthropic.ts +192 -0
- package/src/auth/providers/index.ts +17 -0
- package/src/auth/providers/minimax.ts +100 -0
- package/src/auth/refresh.ts +138 -0
- package/src/auth/store.ts +75 -0
- package/src/auth/types.ts +62 -0
- package/src/compiler/mermaid.ts +109 -0
- package/src/compiler/xstate.ts +615 -0
- package/src/config/index.ts +2 -0
- package/src/config/loader.ts +122 -0
- package/src/config/types.ts +21 -0
- package/src/generators/index.ts +6 -0
- package/src/generators/registry.ts +27 -0
- package/src/generators/typescript.ts +67 -0
- package/src/index.ts +671 -0
- package/src/llm/anthropic.ts +102 -0
- package/src/llm/grok.ts +73 -0
- package/src/llm/index.ts +29 -0
- package/src/llm/ollama.ts +62 -0
- package/src/llm/openai.ts +74 -0
- package/src/llm/provider.ts +35 -0
- package/src/parser/ast-to-markdown.ts +220 -0
- package/src/parser/ast.ts +236 -0
- package/src/parser/markdown-parser.ts +844 -0
- package/src/runtime/effects.ts +48 -0
- package/src/runtime/machine.ts +201 -0
- package/src/runtime/types.ts +44 -0
- package/src/skills.ts +1339 -0
- package/src/tools.ts +144 -0
- package/src/verifier/completeness.ts +89 -0
- package/src/verifier/determinism.ts +328 -0
- package/src/verifier/properties.ts +507 -0
- package/src/verifier/structural.ts +803 -0
- package/src/verifier/types.ts +45 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { AuthProfileStore, AuthProfile } from './types.js';
|
|
5
|
+
|
|
6
|
+
const STORE_VERSION = 1;
|
|
7
|
+
|
|
8
|
+
export function getOrcaDir(): string {
|
|
9
|
+
return join(homedir(), '.orca');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getAuthStorePath(): string {
|
|
13
|
+
return join(getOrcaDir(), 'auth_profiles.json');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ensureOrcaDir(): void {
|
|
17
|
+
const dir = getOrcaDir();
|
|
18
|
+
if (!existsSync(dir)) {
|
|
19
|
+
mkdirSync(dir, { mode: 0o700, recursive: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function loadAuthStore(): AuthProfileStore {
|
|
24
|
+
const path = getAuthStorePath();
|
|
25
|
+
ensureOrcaDir();
|
|
26
|
+
|
|
27
|
+
if (!existsSync(path)) {
|
|
28
|
+
return { version: STORE_VERSION, profiles: {} };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const content = readFileSync(path, 'utf-8');
|
|
33
|
+
const store = JSON.parse(content) as AuthProfileStore;
|
|
34
|
+
return {
|
|
35
|
+
version: store.version ?? STORE_VERSION,
|
|
36
|
+
profiles: store.profiles ?? {},
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
return { version: STORE_VERSION, profiles: {} };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function saveAuthStore(store: AuthProfileStore): void {
|
|
44
|
+
const path = getAuthStorePath();
|
|
45
|
+
ensureOrcaDir();
|
|
46
|
+
|
|
47
|
+
// Set restrictive permissions (owner read/write only)
|
|
48
|
+
writeFileSync(path, JSON.stringify(store, null, 2), { mode: 0o600 });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getAuthProfile(profileId: string): AuthProfile | null {
|
|
52
|
+
const store = loadAuthStore();
|
|
53
|
+
return store.profiles[profileId] ?? null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function setAuthProfile(profileId: string, profile: AuthProfile): void {
|
|
57
|
+
const store = loadAuthStore();
|
|
58
|
+
store.profiles[profileId] = profile;
|
|
59
|
+
saveAuthStore(store);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function deleteAuthProfile(profileId: string): boolean {
|
|
63
|
+
const store = loadAuthStore();
|
|
64
|
+
if (store.profiles[profileId]) {
|
|
65
|
+
delete store.profiles[profileId];
|
|
66
|
+
saveAuthStore(store);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function listAuthProfiles(): string[] {
|
|
73
|
+
const store = loadAuthStore();
|
|
74
|
+
return Object.keys(store.profiles);
|
|
75
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type AuthMode = 'api_key' | 'oauth' | 'token';
|
|
2
|
+
|
|
3
|
+
export interface ApiKeyCredential {
|
|
4
|
+
type: 'api_key';
|
|
5
|
+
provider: string;
|
|
6
|
+
key: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OAuthCredential {
|
|
11
|
+
type: 'oauth';
|
|
12
|
+
provider: string;
|
|
13
|
+
access: string;
|
|
14
|
+
refresh: string;
|
|
15
|
+
expires: number; // Unix timestamp
|
|
16
|
+
email?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TokenCredential {
|
|
20
|
+
type: 'token';
|
|
21
|
+
provider: string;
|
|
22
|
+
token: string;
|
|
23
|
+
expires?: number; // Unix timestamp
|
|
24
|
+
email?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type AuthCredential = ApiKeyCredential | OAuthCredential | TokenCredential;
|
|
28
|
+
|
|
29
|
+
export interface AuthProfile {
|
|
30
|
+
mode: AuthMode;
|
|
31
|
+
provider: string;
|
|
32
|
+
email?: string;
|
|
33
|
+
// api_key mode
|
|
34
|
+
key?: string;
|
|
35
|
+
keyRef?: string;
|
|
36
|
+
// token mode
|
|
37
|
+
token?: string;
|
|
38
|
+
tokenRef?: string;
|
|
39
|
+
// oauth mode
|
|
40
|
+
access?: string;
|
|
41
|
+
refresh?: string;
|
|
42
|
+
expires?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface AuthProfileStore {
|
|
46
|
+
version: number;
|
|
47
|
+
profiles: Record<string, AuthProfile>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AuthProfileResult {
|
|
51
|
+
apiKey: string;
|
|
52
|
+
provider: string;
|
|
53
|
+
email?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type OAuthProvider = 'anthropic' | 'minimax';
|
|
57
|
+
|
|
58
|
+
export interface TokenRefreshResult {
|
|
59
|
+
access: string;
|
|
60
|
+
refresh?: string;
|
|
61
|
+
expires: number;
|
|
62
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { MachineDef, StateDef } from '../parser/ast.js';
|
|
2
|
+
|
|
3
|
+
export function compileToMermaid(machine: MachineDef): string {
|
|
4
|
+
const lines: string[] = [];
|
|
5
|
+
|
|
6
|
+
lines.push(`stateDiagram-v2`);
|
|
7
|
+
lines.push(` direction LR`);
|
|
8
|
+
lines.push(``);
|
|
9
|
+
|
|
10
|
+
// Add initial state transition
|
|
11
|
+
lines.push(` [*] --> ${getInitialStateName(machine)}`);
|
|
12
|
+
|
|
13
|
+
// Add termination transitions for top-level final states
|
|
14
|
+
for (const state of machine.states) {
|
|
15
|
+
if (state.isFinal) {
|
|
16
|
+
lines.push(` ${state.name} --> [*]`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
lines.push(``);
|
|
21
|
+
|
|
22
|
+
// Render compound/parallel state bodies
|
|
23
|
+
for (const state of machine.states) {
|
|
24
|
+
renderStateBody(state, machine, lines, ' ');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Add transitions
|
|
28
|
+
for (const t of machine.transitions) {
|
|
29
|
+
let label = t.event;
|
|
30
|
+
if (t.guard) {
|
|
31
|
+
label += ` [${t.guard.negated ? '!' : ''}${t.guard.name}]`;
|
|
32
|
+
}
|
|
33
|
+
if (t.action && t.action !== '_') {
|
|
34
|
+
label += ` / ${t.action}`;
|
|
35
|
+
}
|
|
36
|
+
lines.push(` ${t.source} --> ${t.target} : ${label}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return lines.join('\n');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function renderStateBody(state: StateDef, machine: MachineDef, lines: string[], indent: string): void {
|
|
43
|
+
// Hierarchical compound states
|
|
44
|
+
if (state.contains && state.contains.length > 0) {
|
|
45
|
+
lines.push(`${indent}state ${state.name} {`);
|
|
46
|
+
const inner = indent + ' ';
|
|
47
|
+
|
|
48
|
+
// Initial child transition
|
|
49
|
+
const initialChild = state.contains.find(s => s.isInitial) || state.contains[0];
|
|
50
|
+
lines.push(`${inner}[*] --> ${initialChild.name}`);
|
|
51
|
+
|
|
52
|
+
// Final child transitions
|
|
53
|
+
for (const child of state.contains) {
|
|
54
|
+
if (child.isFinal) {
|
|
55
|
+
lines.push(`${inner}${child.name} --> [*]`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Recurse into children that are themselves compound/parallel
|
|
60
|
+
for (const child of state.contains) {
|
|
61
|
+
renderStateBody(child, machine, lines, inner);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
lines.push(`${indent}}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Parallel states
|
|
68
|
+
if (state.parallel) {
|
|
69
|
+
lines.push(`${indent}state ${state.name} {`);
|
|
70
|
+
const inner = indent + ' ';
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < state.parallel.regions.length; i++) {
|
|
73
|
+
const region = state.parallel.regions[i];
|
|
74
|
+
|
|
75
|
+
// Region separator between regions
|
|
76
|
+
if (i > 0) {
|
|
77
|
+
lines.push(`${inner}--`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
lines.push(`${inner}state ${region.name} {`);
|
|
81
|
+
const regionInner = inner + ' ';
|
|
82
|
+
|
|
83
|
+
// Initial child transition within region
|
|
84
|
+
const initialChild = region.states.find(s => s.isInitial) || region.states[0];
|
|
85
|
+
lines.push(`${regionInner}[*] --> ${initialChild.name}`);
|
|
86
|
+
|
|
87
|
+
// Final child transitions within region
|
|
88
|
+
for (const child of region.states) {
|
|
89
|
+
if (child.isFinal) {
|
|
90
|
+
lines.push(`${regionInner}${child.name} --> [*]`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Recurse into children
|
|
95
|
+
for (const child of region.states) {
|
|
96
|
+
renderStateBody(child, machine, lines, regionInner);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
lines.push(`${inner}}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
lines.push(`${indent}}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getInitialStateName(machine: MachineDef): string {
|
|
107
|
+
const initial = machine.states.find(s => s.isInitial);
|
|
108
|
+
return initial?.name || machine.states[0]?.name || 'unknown';
|
|
109
|
+
}
|