Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/core/openclaw/main.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / core / openclaw / main.om` 194 lines ยท 3235 bytes Raw Blame History 1 note core/openclaw/main.om: CLI entrypoint for pure-Omega openclaw agent runtime 2 note Composed after si/directives/om2.om and core/openclaw/lib.om. 3 note Reads line-delimited JSON tool-call envelopes on stdin, drives the deterministic 4 note turn state machine, and emits JSONL turn outcomes on stdout. 5 6 const CLI_IN_CAP ulong 65536 7 global cli_in uchar 65536 8 global cli_in_len ulong 1 9 global cli_parsed_u64 ulong 1 10 11 text fl_caps "--caps" 12 text fl_budget "--budget" 13 text fl_turns "--max-turns" 14 text cli_err_io "openclaw: I/O error\n" 15 text cli_err_args "openclaw: invalid or excessive CLI arguments\n" 16 17 fn cli_buf_eq buf view uchar * n ulong pat view uchar * to bool 18 if ne n len pat 19 ret false 20 end 21 for i ulong n bound 64 22 if ne get buf i get pat i 23 ret false 24 end 25 end 26 ret true 27 end 28 29 fn cli_parse_u64_ok buf view uchar * n ulong to bool 30 if or eq n 0 gt n 20 31 ret false 32 end 33 val = ulong 0 34 for i ulong n bound 64 35 c = get buf i 36 if not and ge c 48 le c 57 37 ret false 38 end 39 d = ulong sub c 48 40 if gt val ulong `1844674407370955161` 41 ret false 42 end 43 if and eq val ulong `1844674407370955161` gt d 5 44 ret false 45 end 46 val = add mul val 10 d 47 end 48 put cli_parsed_u64 0 val 49 ret true 50 end 51 52 fn cli_read_stdin to long 53 total = ulong 0 54 while lt total CLI_IN_CAP bound 65536 55 k = read 0 cli_in total sub CLI_IN_CAP total 56 if lt k 0 57 ret k 58 end 59 if eq k 0 60 break 61 end 62 total = add total ulong k 63 end 64 put cli_in_len 0 total 65 ret long total 66 end 67 68 fn cli_load_line ls ulong nlen ulong to void 69 n = nlen 70 if gt n OC_ENV_CAP 71 n = OC_ENV_CAP 72 end 73 for i ulong n bound 4096 74 put oc_env i get cli_in add ls i 75 end 76 put oc_env_len 0 n 77 end 78 79 fn cli_flag_kind buf view uchar * n ulong to ulong 80 if cli_buf_eq buf n fl_caps 81 ret 1 82 end 83 if cli_buf_eq buf n fl_budget 84 ret 2 85 end 86 if cli_buf_eq buf n fl_turns 87 ret 3 88 end 89 ret 0 90 end 91 92 fn cli_read_arg_u64 idx ulong to bool 93 vbuf = new uchar 64 0 94 rv = argread idx vbuf 0 64 95 if le rv 0 96 ret false 97 end 98 ret cli_parse_u64_ok vbuf ulong rv 99 end 100 101 fn cli_init_from_args to bool 102 ac_raw = argcnt 103 if or lt ac_raw 0 gt ac_raw 64 104 ret false 105 end 106 caps = or CAP_READ CAP_WRITE 107 max_t = ulong 32 108 tok_b = ulong 4096 109 ac = ulong ac_raw 110 abuf = new uchar 64 0 111 i = ulong 1 112 while lt i ac bound 64 113 r = argread i abuf 0 64 114 if gt r 0 115 fk = cli_flag_kind abuf ulong r 116 if gt fk 0 117 if ge add i 1 ac 118 ret false 119 end 120 if not cli_read_arg_u64 add i 1 121 ret false 122 end 123 if eq fk 1 124 caps = get cli_parsed_u64 0 125 else 126 if eq fk 2 127 tok_b = get cli_parsed_u64 0 128 else 129 max_t = get cli_parsed_u64 0 130 end 131 end 132 i = add i 1 133 end 134 end 135 i = add i 1 136 end 137 oc_session_init caps max_t tok_b max_t 138 ret true 139 end 140 141 fn cli_process_lines to int 142 total = get cli_in_len 0 143 pos = ulong 0 144 while lt pos total bound 65536 145 ls = pos 146 while lt pos total bound 65536 147 if eq get cli_in pos 10 148 break 149 end 150 pos = add pos 1 151 end 152 le_p = pos 153 if gt le_p ls 154 if eq get cli_in sub le_p 1 13 155 le_p = sub le_p 1 156 end 157 end 158 if gt le_p ls 159 cli_load_line ls sub le_p ls 160 st = oc_run_turn 161 if gt st ST_REFUSED 162 ret 2 163 end 164 olen = oc_format_turn_jsonl 165 ok = oc_write_out 1 olen 166 if not ok 167 ret 2 168 end 169 end 170 if lt pos total 171 pos = add pos 1 172 end 173 end 174 ret 0 175 end 176 177 fn main to int 178 if not cli_init_from_args 179 ea = write 2 cli_err_args 0 len cli_err_args 180 if lt ea 0 181 ret 2 182 end 183 ret 2 184 end 185 got = cli_read_stdin 186 if lt got 0 187 ew = write 2 cli_err_io 0 len cli_err_io 188 if lt ew 0 189 ret 2 190 end 191 ret 2 192 end 193 ret cli_process_lines 194 end