omega-mcp
aien-dev/omega-mcp
Brought by drakestapleton
| 1 | note Agent Q&A MCP transport: newline-delimited JSON-RPC 2.0 on stdio, framing copied from maintenance/rpc.om. |
| 2 | global arrpc ulong 8 |
| 3 | text arj "jsonrpc" |
| 4 | text arid "id" |
| 5 | text arm "method" |
| 6 | text arp "params" |
| 7 | text arn "name" |
| 8 | text ara "arguments" |
| 9 | text arres "result" |
| 10 | text arerr "error" |
| 11 | text arcode "code" |
| 12 | text armsg "message" |
| 13 | text arver "2.0" |
| 14 | text arinit "initialize" |
| 15 | text arping "ping" |
| 16 | text arlist "tools/list" |
| 17 | text arcall "tools/call" |
| 18 | text arpv "protocolVersion" |
| 19 | text arpv1 "2025-06-18" |
| 20 | text arpv2 "2025-03-26" |
| 21 | text arpv3 "2024-11-05" |
| 22 | text artools "tools" |
| 23 | text arsc "structuredContent" |
| 24 | text arc "content" |
| 25 | text artext "text" |
| 26 | text artype "type" |
| 27 | text ariserr "isError" |
| 28 | text arnl "\n" |
| 29 | text areparse "Malformed or oversized JSON frame" |
| 30 | text areinv "Invalid JSON-RPC request: object, jsonrpc 2.0, string method and string/integer id required" |
| 31 | text arepar "Invalid params: the tool's named string arguments, each present once, within its maxLength" |
| 32 | text aremeth "Method not found" |
| 33 | text arcap "capabilities" |
| 34 | text arlc "listChanged" |
| 35 | text arsi "serverInfo" |
| 36 | text arversio "version" |
| 37 | text arserver "omega-agent-qa" |
| 38 | text arvers "0.1.0" |
| 39 | text arinst "instructions" |
| 40 | text arhelp "Shared questions and answers for coding agents. Before you spend long on an error, call search with a few words from it. Read answers with read and run their evidence yourself before relying on them: an answer is a claim until it reproduces. When you solve something others may hit, and consent_status says may_contribute, ask, answer or check (works or fails, with evidence). If may_contribute is false, tell the person once, plainly, that sharing is off and quote how_to_enable; never edit the consent file yourself. Share only what the entry needs: no chat, private code, file contents, keys or home paths." |
| 41 | text ardesc "description" |
| 42 | text arschema "inputSchema" |
| 43 | text arprops "properties" |
| 44 | text arreq "required" |
| 45 | text aradd "additionalProperties" |
| 46 | text arobj "object" |
| 47 | text arstr "string" |
| 48 | text armax "maxLength" |
| 49 | text arpatter "pattern" |
| 50 | text arhashpa "^[0-9a-f]{64}$" |
| 51 | text arrespa "^(works|fails)$" |
| 52 | text arsummar "See structuredContent for the exact result." |
| 53 | text ar0 "search" |
| 54 | text ar1 "read" |
| 55 | text ar2 "consent_status" |
| 56 | text ar3 "ask" |
| 57 | text ar4 "answer" |
| 58 | text ar5 "check" |
| 59 | text ard0 "Find shared entries whose text holds every space-separated word of words (ASCII case-insensitive; empty lists all). Returns id, kind, title and ref of up to 50, the total matches, more when there are further matches (add words to narrow) and skipped damaged files. Open to every agent." |
| 60 | text ard1 "Read one entry's exact text by its id (the SHA-256 of the text, checked on read). Open to every agent." |
| 61 | text ard2 "Whether this agent may contribute, the consent file, and one plain sentence for the person on how to turn sharing on or off. Reading never needs consent." |
| 62 | text ard3 "Post a question (needs consent). title and versions are one line each (tool, compiler, OS versions); body is the problem with the smallest reproduction. Refused, never edited, if it holds keys, tokens or home paths. Returns the entry id." |
| 63 | text ard4 "Post an answer to a question id (needs consent): versions it was proven on, steps to apply it, evidence (one line: the command that shows it works and its result) and body. Refused if it holds keys, tokens or home paths." |
| 64 | text ard5 "Confirm or challenge an answer id (needs consent): result works or fails, evidence (the command you ran and what it printed) and body (what you saw). Refused if it holds keys, tokens or home paths." |
| 65 | text arf0 "words" |
| 66 | text arf1 "id" |
| 67 | text arf2 "title" |
| 68 | text arf3 "versions" |
| 69 | text arf4 "body" |
| 70 | text arf5 "question" |
| 71 | text arf6 "answer" |
| 72 | text arf7 "steps" |
| 73 | text arf8 "evidence" |
| 74 | text arf9 "result" |
| 75 | text areinter "Internal error: the result is not a complete JSON object" |
| 76 | |
| 77 | fn arwt ob edit uchar 787472 s view uchar * to void |
| 78 | js_wsbuf ob s 0 len s |
| 79 | end |
| 80 | |
| 81 | fn arpair ob edit uchar 787472 key view uchar * value view uchar * to void |
| 82 | arwt ob key |
| 83 | arwt ob value |
| 84 | end |
| 85 | |
| 86 | fn armem src view uchar 524288 tape view uint 65536 obj ulong key view uchar * to ulong |
| 87 | if ne js_type tape obj jsobj |
| 88 | ret jsnone |
| 89 | end |
| 90 | k = js_first tape obj |
| 91 | while ne k jsnone bound 999999 |
| 92 | if js_streq src js_off tape k key |
| 93 | ret add k 1 |
| 94 | end |
| 95 | k = js_mnext tape k |
| 96 | end |
| 97 | ret jsnone |
| 98 | end |
| 99 | |
| 100 | fn arfull src view uchar * off ulong n ulong to bool |
| 101 | p = ulong 0 |
| 102 | while lt p n bound 999999 |
| 103 | r = write 1 src add off p sub n p |
| 104 | if eq r -4 |
| 105 | continue |
| 106 | end |
| 107 | if le r 0 |
| 108 | ret false |
| 109 | end |
| 110 | p = add p ulong r |
| 111 | end |
| 112 | ret true |
| 113 | end |
| 114 | |
| 115 | fn arbegin src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void |
| 116 | z = js_winit ob |
| 117 | js_wobj ob |
| 118 | arpair ob arj arver |
| 119 | arwt ob arid |
| 120 | t = get arrpc 0 |
| 121 | if eq t jsnone |
| 122 | js_wnull ob |
| 123 | else |
| 124 | js_wtok ob src js_type tape t js_off tape t |
| 125 | end |
| 126 | end |
| 127 | |
| 128 | fn arsend ob edit uchar 787472 to void |
| 129 | js_wobje ob |
| 130 | n = js_wdone ob |
| 131 | if lt n 0 |
| 132 | exit 5 |
| 133 | end |
| 134 | ok = arfull ob 1040 ulong n |
| 135 | if not ok |
| 136 | exit 6 |
| 137 | end |
| 138 | ok = arfull arnl 0 1 |
| 139 | if not ok |
| 140 | exit 6 |
| 141 | end |
| 142 | end |
| 143 | |
| 144 | fn arerror src view uchar 524288 tape view uint 65536 ob edit uchar 787472 code long msg view uchar * to void |
| 145 | arbegin src tape ob |
| 146 | arwt ob arerr |
| 147 | js_wobj ob |
| 148 | arwt ob arcode |
| 149 | js_wlong ob code |
| 150 | arpair ob armsg msg |
| 151 | js_wobje ob |
| 152 | arsend ob |
| 153 | end |
| 154 | |
| 155 | fn arhandle src view uchar 524288 tape edit uint 65536 ob edit uchar 787472 n ulong to void |
| 156 | put arrpc 0 jsnone |
| 157 | r = js_parse src tape n |
| 158 | if lt r 0 |
| 159 | arerror src tape ob -32700 areparse |
| 160 | ret |
| 161 | end |
| 162 | v = armem src tape 0 arj |
| 163 | m = armem src tape 0 arm |
| 164 | id = armem src tape 0 arid |
| 165 | valid = eq js_type tape 0 jsobj |
| 166 | if ne js_type tape v jsstr |
| 167 | valid = false |
| 168 | else |
| 169 | if not js_streq src js_off tape v arver |
| 170 | valid = false |
| 171 | end |
| 172 | end |
| 173 | if ne js_type tape m jsstr |
| 174 | valid = false |
| 175 | end |
| 176 | if ne id jsnone |
| 177 | ty = js_type tape id |
| 178 | if eq ty jsstr |
| 179 | put arrpc 0 id |
| 180 | else |
| 181 | if eq ty jsnum |
| 182 | if ne js_ilex src js_off tape id 0 |
| 183 | put arrpc 0 id |
| 184 | else |
| 185 | valid = false |
| 186 | end |
| 187 | else |
| 188 | valid = false |
| 189 | end |
| 190 | end |
| 191 | end |
| 192 | note Duplicate envelope fields are ambiguous and cannot execute. |
| 193 | if valid |
| 194 | k = js_first tape 0 |
| 195 | seen = ulong 0 |
| 196 | while ne k jsnone bound 999999 |
| 197 | bit = ulong 0 |
| 198 | if js_streq src js_off tape k arj |
| 199 | bit = 1 |
| 200 | end |
| 201 | if js_streq src js_off tape k arm |
| 202 | bit = 2 |
| 203 | end |
| 204 | if js_streq src js_off tape k arid |
| 205 | bit = 4 |
| 206 | end |
| 207 | if js_streq src js_off tape k arp |
| 208 | bit = 8 |
| 209 | end |
| 210 | if ne and seen bit 0 |
| 211 | valid = false |
| 212 | end |
| 213 | seen = or seen bit |
| 214 | k = js_mnext tape k |
| 215 | end |
| 216 | end |
| 217 | if not valid |
| 218 | arerror src tape ob -32600 areinv |
| 219 | ret |
| 220 | end |
| 221 | note Valid notifications have neither response nor storage effects. |
| 222 | if eq id jsnone |
| 223 | ret |
| 224 | end |
| 225 | p = armem src tape 0 arp |
| 226 | put arrpc 1 p |
| 227 | if ne p jsnone |
| 228 | if ne js_type tape p jsobj |
| 229 | arerror src tape ob -32602 arepar |
| 230 | ret |
| 231 | end |
| 232 | end |
| 233 | if js_streq src js_off tape m arinit |
| 234 | arinitialize src tape ob |
| 235 | ret |
| 236 | end |
| 237 | if js_streq src js_off tape m arcall |
| 238 | artoolcall src tape ob |
| 239 | ret |
| 240 | end |
| 241 | if js_streq src js_off tape m arping |
| 242 | arbegin src tape ob |
| 243 | arwt ob arres |
| 244 | js_wobj ob |
| 245 | js_wobje ob |
| 246 | arsend ob |
| 247 | ret |
| 248 | end |
| 249 | if js_streq src js_off tape m arlist |
| 250 | arbegin src tape ob |
| 251 | arwt ob arres |
| 252 | js_wobj ob |
| 253 | arwt ob artools |
| 254 | js_warr ob |
| 255 | for op ulong 6 |
| 256 | arschemawrite ob op |
| 257 | end |
| 258 | js_warre ob |
| 259 | js_wobje ob |
| 260 | arsend ob |
| 261 | ret |
| 262 | end |
| 263 | arerror src tape ob -32601 aremeth |
| 264 | end |
| 265 | |
| 266 | fn arframe src view uchar 524288 tape edit uint 65536 ob edit uchar 787472 to void |
| 267 | if ne get arrpc 7 0 |
| 268 | put arrpc 0 jsnone |
| 269 | arerror src tape ob -32700 areparse |
| 270 | else |
| 271 | arhandle src tape ob get arrpc 6 |
| 272 | end |
| 273 | put arrpc 6 0 |
| 274 | put arrpc 7 0 |
| 275 | end |
| 276 | |
| 277 | fn arfeed src edit uchar 524288 tape edit uint 65536 ob edit uchar 787472 chunk view uchar 4096 n ulong to void |
| 278 | for i ulong n |
| 279 | c = get chunk i |
| 280 | if eq c 10 |
| 281 | arframe src tape ob |
| 282 | else |
| 283 | if eq get arrpc 7 0 |
| 284 | p = get arrpc 6 |
| 285 | if ge p len src |
| 286 | put arrpc 7 1 |
| 287 | else |
| 288 | put src p c |
| 289 | put arrpc 6 add p 1 |
| 290 | end |
| 291 | end |
| 292 | end |
| 293 | end |
| 294 | end |
| 295 | |
| 296 | fn arfname ob edit uchar 787472 f ulong to void |
| 297 | if eq f 0 |
| 298 | arwt ob arf0 |
| 299 | end |
| 300 | if eq f 1 |
| 301 | arwt ob arf1 |
| 302 | end |
| 303 | if eq f 2 |
| 304 | arwt ob arf2 |
| 305 | end |
| 306 | if eq f 3 |
| 307 | arwt ob arf3 |
| 308 | end |
| 309 | if eq f 4 |
| 310 | arwt ob arf4 |
| 311 | end |
| 312 | if eq f 5 |
| 313 | arwt ob arf5 |
| 314 | end |
| 315 | if eq f 6 |
| 316 | arwt ob arf6 |
| 317 | end |
| 318 | if eq f 7 |
| 319 | arwt ob arf7 |
| 320 | end |
| 321 | if eq f 8 |
| 322 | arwt ob arf8 |
| 323 | end |
| 324 | if eq f 9 |
| 325 | arwt ob arf9 |
| 326 | end |
| 327 | end |
| 328 | note The fields each tool takes, as bits of the field slots in qa/store.om (all required, no others): |
| 329 | note ask 4+8+16=28, answer 32+8+128+256+16=440, check 64+512+256+16=848 (aien-calc receipts in the commit message). |
| 330 | fn armask op ulong to ulong |
| 331 | if eq op 0 |
| 332 | ret 1 |
| 333 | end |
| 334 | if eq op 1 |
| 335 | ret 2 |
| 336 | end |
| 337 | if eq op 2 |
| 338 | ret 0 |
| 339 | end |
| 340 | if eq op 3 |
| 341 | ret 28 |
| 342 | end |
| 343 | if eq op 4 |
| 344 | ret 440 |
| 345 | end |
| 346 | ret 848 |
| 347 | end |
| 348 | note Largest accepted length of each field in bytes after JSON unescaping; every entry stays under qmax. |
| 349 | fn arcapof f ulong to ulong |
| 350 | if eq f 0 |
| 351 | ret 256 |
| 352 | end |
| 353 | if or or eq f 1 eq f 5 eq f 6 |
| 354 | ret 64 |
| 355 | end |
| 356 | if or eq f 2 eq f 3 |
| 357 | ret 200 |
| 358 | end |
| 359 | if eq f 4 |
| 360 | ret 32768 |
| 361 | end |
| 362 | if eq f 7 |
| 363 | ret 16384 |
| 364 | end |
| 365 | if eq f 8 |
| 366 | ret 1000 |
| 367 | end |
| 368 | ret 5 |
| 369 | end |
| 370 | fn arname ob edit uchar 787472 op ulong to void |
| 371 | if eq op 0 |
| 372 | arwt ob ar0 |
| 373 | end |
| 374 | if eq op 1 |
| 375 | arwt ob ar1 |
| 376 | end |
| 377 | if eq op 2 |
| 378 | arwt ob ar2 |
| 379 | end |
| 380 | if eq op 3 |
| 381 | arwt ob ar3 |
| 382 | end |
| 383 | if eq op 4 |
| 384 | arwt ob ar4 |
| 385 | end |
| 386 | if eq op 5 |
| 387 | arwt ob ar5 |
| 388 | end |
| 389 | end |
| 390 | fn ardescription ob edit uchar 787472 op ulong to void |
| 391 | if eq op 0 |
| 392 | arwt ob ard0 |
| 393 | end |
| 394 | if eq op 1 |
| 395 | arwt ob ard1 |
| 396 | end |
| 397 | if eq op 2 |
| 398 | arwt ob ard2 |
| 399 | end |
| 400 | if eq op 3 |
| 401 | arwt ob ard3 |
| 402 | end |
| 403 | if eq op 4 |
| 404 | arwt ob ard4 |
| 405 | end |
| 406 | if eq op 5 |
| 407 | arwt ob ard5 |
| 408 | end |
| 409 | end |
| 410 | fn arschemawrite ob edit uchar 787472 op ulong to void |
| 411 | m = armask op |
| 412 | js_wobj ob |
| 413 | arwt ob arn |
| 414 | arname ob op |
| 415 | arwt ob ardesc |
| 416 | ardescription ob op |
| 417 | arwt ob arschema |
| 418 | js_wobj ob |
| 419 | arpair ob artype arobj |
| 420 | arwt ob aradd |
| 421 | js_wbool ob false |
| 422 | arwt ob arprops |
| 423 | js_wobj ob |
| 424 | for f ulong 10 |
| 425 | if ne and m shl 1 f 0 |
| 426 | arfname ob f |
| 427 | js_wobj ob |
| 428 | arpair ob artype arstr |
| 429 | arwt ob armax |
| 430 | js_wulong ob arcapof f |
| 431 | if or or eq f 1 eq f 5 eq f 6 |
| 432 | arpair ob arpatter arhashpa |
| 433 | end |
| 434 | if eq f 9 |
| 435 | arpair ob arpatter arrespa |
| 436 | end |
| 437 | js_wobje ob |
| 438 | end |
| 439 | end |
| 440 | js_wobje ob |
| 441 | arwt ob arreq |
| 442 | js_warr ob |
| 443 | for f ulong 10 |
| 444 | if ne and m shl 1 f 0 |
| 445 | arfname ob f |
| 446 | end |
| 447 | end |
| 448 | js_warre ob |
| 449 | js_wobje ob |
| 450 | js_wobje ob |
| 451 | end |
| 452 | fn arinitialize src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void |
| 453 | p = get arrpc 1 |
| 454 | v = armem src tape p arpv |
| 455 | if ne js_type tape v jsstr |
| 456 | arerror src tape ob -32602 arepar |
| 457 | ret |
| 458 | end |
| 459 | arbegin src tape ob |
| 460 | arwt ob arres |
| 461 | js_wobj ob |
| 462 | arwt ob arpv |
| 463 | if js_streq src js_off tape v arpv2 |
| 464 | arwt ob arpv2 |
| 465 | else |
| 466 | if js_streq src js_off tape v arpv3 |
| 467 | arwt ob arpv3 |
| 468 | else |
| 469 | arwt ob arpv1 |
| 470 | end |
| 471 | end |
| 472 | arwt ob arcap |
| 473 | js_wobj ob |
| 474 | arwt ob artools |
| 475 | js_wobj ob |
| 476 | arwt ob arlc |
| 477 | js_wbool ob false |
| 478 | js_wobje ob |
| 479 | js_wobje ob |
| 480 | arwt ob arsi |
| 481 | js_wobj ob |
| 482 | arpair ob arn arserver |
| 483 | arpair ob arversio arvers |
| 484 | js_wobje ob |
| 485 | arpair ob arinst arhelp |
| 486 | js_wobje ob |
| 487 | arsend ob |
| 488 | end |
| 489 | fn artoolop src view uchar 524288 off ulong to ulong |
| 490 | if js_streq src off ar0 |
| 491 | ret 0 |
| 492 | end |
| 493 | if js_streq src off ar1 |
| 494 | ret 1 |
| 495 | end |
| 496 | if js_streq src off ar2 |
| 497 | ret 2 |
| 498 | end |
| 499 | if js_streq src off ar3 |
| 500 | ret 3 |
| 501 | end |
| 502 | if js_streq src off ar4 |
| 503 | ret 4 |
| 504 | end |
| 505 | if js_streq src off ar5 |
| 506 | ret 5 |
| 507 | end |
| 508 | ret jsnone |
| 509 | end |
| 510 | fn arfieldof src view uchar 524288 off ulong to ulong |
| 511 | if js_streq src off arf0 |
| 512 | ret 0 |
| 513 | end |
| 514 | if js_streq src off arf1 |
| 515 | ret 1 |
| 516 | end |
| 517 | if js_streq src off arf2 |
| 518 | ret 2 |
| 519 | end |
| 520 | if js_streq src off arf3 |
| 521 | ret 3 |
| 522 | end |
| 523 | if js_streq src off arf4 |
| 524 | ret 4 |
| 525 | end |
| 526 | if js_streq src off arf5 |
| 527 | ret 5 |
| 528 | end |
| 529 | if js_streq src off arf6 |
| 530 | ret 6 |
| 531 | end |
| 532 | if js_streq src off arf7 |
| 533 | ret 7 |
| 534 | end |
| 535 | if js_streq src off arf8 |
| 536 | ret 8 |
| 537 | end |
| 538 | if js_streq src off arf9 |
| 539 | ret 9 |
| 540 | end |
| 541 | ret jsnone |
| 542 | end |
| 543 | note Exactly the tool's fields, each once, each a string; values are unescaped into fv slot by slot and a |
| 544 | note value longer than its cap (after unescaping) refuses the call. |
| 545 | fn arput src view uchar 524288 off ulong f ulong fv edit uchar 327680 fl edit ulong 10 to bool |
| 546 | tmp = new uchar 32768 0 |
| 547 | n = js_sget src off tmp |
| 548 | if lt n 0 |
| 549 | ret false |
| 550 | end |
| 551 | if gt ulong n arcapof f |
| 552 | ret false |
| 553 | end |
| 554 | for i ulong ulong n |
| 555 | put fv add mul f qfmax i get tmp i |
| 556 | end |
| 557 | put fl f ulong n |
| 558 | ret true |
| 559 | end |
| 560 | fn arfill src view uchar 524288 tape view uint 65536 a ulong op ulong fv edit uchar 327680 fl edit ulong 10 to bool |
| 561 | if ne js_type tape a jsobj |
| 562 | ret false |
| 563 | end |
| 564 | m = armask op |
| 565 | seen = ulong 0 |
| 566 | k = js_first tape a |
| 567 | while ne k jsnone bound 64 |
| 568 | f = arfieldof src js_off tape k |
| 569 | if eq f jsnone |
| 570 | ret false |
| 571 | end |
| 572 | b = shl 1 f |
| 573 | if eq and m b 0 |
| 574 | ret false |
| 575 | end |
| 576 | if ne and seen b 0 |
| 577 | ret false |
| 578 | end |
| 579 | seen = or seen b |
| 580 | v = add k 1 |
| 581 | if ne js_type tape v jsstr |
| 582 | ret false |
| 583 | end |
| 584 | if gt js_slen tape v 32768 |
| 585 | ret false |
| 586 | end |
| 587 | if not arput src js_off tape v f fv fl |
| 588 | ret false |
| 589 | end |
| 590 | k = js_mnext tape k |
| 591 | end |
| 592 | ret eq seen m |
| 593 | end |
| 594 | note Exactly the tool's fields, each once, each a string within its cap after unescaping; else -32602. |
| 595 | fn arinvoke src view uchar 524288 tape view uint 65536 ob edit uchar 787472 a ulong op ulong to void |
| 596 | fv = new uchar 327680 0 |
| 597 | fl = new ulong 10 0 |
| 598 | if not arfill src tape a op fv fl |
| 599 | arerror src tape ob -32602 arepar |
| 600 | ret |
| 601 | end |
| 602 | arresult src tape ob op fv fl |
| 603 | end |
| 604 | fn arresult src view uchar 524288 tape view uint 65536 ob edit uchar 787472 op ulong fv view uchar 327680 fl view ulong 10 to void |
| 605 | arbegin src tape ob |
| 606 | arwt ob arres |
| 607 | js_wobj ob |
| 608 | arwt ob arsc |
| 609 | ok = qa_call op fv fl ob |
| 610 | arwt ob arc |
| 611 | js_warr ob |
| 612 | js_wobj ob |
| 613 | arpair ob artype artext |
| 614 | arpair ob artext arsummar |
| 615 | js_wobje ob |
| 616 | js_warre ob |
| 617 | arwt ob ariserr |
| 618 | js_wbool ob ne get qerr 0 0 |
| 619 | js_wobje ob |
| 620 | arsend ob |
| 621 | end |
| 622 | |
| 623 | fn artoolcall src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void |
| 624 | p = get arrpc 1 |
| 625 | n = armem src tape p arn |
| 626 | a = armem src tape p ara |
| 627 | if ne js_type tape n jsstr |
| 628 | arerror src tape ob -32602 arepar |
| 629 | ret |
| 630 | end |
| 631 | op = artoolop src js_off tape n |
| 632 | if eq op jsnone |
| 633 | arerror src tape ob -32602 arepar |
| 634 | ret |
| 635 | end |
| 636 | if eq a jsnone |
| 637 | if ne armask op 0 |
| 638 | arerror src tape ob -32602 arepar |
| 639 | ret |
| 640 | end |
| 641 | end |
| 642 | if or gt js_nkids tape p 2 and eq a jsnone gt js_nkids tape p 1 |
| 643 | arerror src tape ob -32602 arepar |
| 644 | ret |
| 645 | end |
| 646 | if eq a jsnone |
| 647 | arinvoke0 src tape ob op |
| 648 | ret |
| 649 | end |
| 650 | arinvoke src tape ob a op |
| 651 | end |
| 652 | fn arinvoke0 src view uchar 524288 tape view uint 65536 ob edit uchar 787472 op ulong to void |
| 653 | fv = new uchar 327680 0 |
| 654 | fl = new ulong 10 0 |
| 655 | arresult src tape ob op fv fl |
| 656 | end |
| 657 | |
| 658 | fn main to int |
| 659 | src = new uchar 524288 0 |
| 660 | tape = new uint 65536 0 |
| 661 | ob = new uchar 787472 0 |
| 662 | chunk = new uchar 4096 0 |
| 663 | b = qa_boot |
| 664 | if ne b 0 |
| 665 | ret b |
| 666 | end |
| 667 | z = js_init tape 524288 64 |
| 668 | if lt z 0 |
| 669 | ret 4 |
| 670 | end |
| 671 | note Each read consumes bytes or EOF; nested bounded epochs permit a long-lived stdio connection. |
| 672 | for epoch ulong 999999 |
| 673 | for tick ulong 999999 |
| 674 | r = read 0 chunk 0 len chunk |
| 675 | if eq r -4 |
| 676 | continue |
| 677 | end |
| 678 | if lt r 0 |
| 679 | ret 7 |
| 680 | end |
| 681 | if eq r 0 |
| 682 | if or ne get arrpc 6 0 ne get arrpc 7 0 |
| 683 | arframe src tape ob |
| 684 | end |
| 685 | ret 0 |
| 686 | end |
| 687 | arfeed src tape ob chunk ulong r |
| 688 | end |
| 689 | end |
| 690 | ret 0 |
| 691 | end |