interplane.Get Omega
Read in your language

omega-mcp

aien-dev/omega-mcp

Brought by drakestapleton

branch main Branches Tags History

omega-mcp / maintenance / rpc.om

633 lines · 13169 bytes Raw Blame History
1note Maintenance MCP transport; storage is deliberately independent of compiler sandbox/server units.
2note arrpc: id, params, op, file token, body token, token token, frame length, oversize.
3global arrpc ulong 8
4text arj "jsonrpc"
5text arid "id"
6text arm "method"
7text arp "params"
8text arn "name"
9text ara "arguments"
10text arf "file"
11text arc "content"
12text arh "expected_sha256"
13text art "proposal_id"
14text arres "result"
15text arerr "error"
16text arcode "code"
17text armsg "message"
18text arver "2.0"
19text arinit "initialize"
20text arping "ping"
21text arlist "tools/list"
22text arcall "tools/call"
23text arpv "protocolVersion"
24text arpv1 "2025-06-18"
25text arpv2 "2025-03-26"
26text arpv3 "2024-11-05"
27text artools "tools"
28text arsc "structuredContent"
29text artext "text"
30text artype "type"
31text ariserr "isError"
32text arnl "\n"
33text areparse "Malformed or oversized JSON frame"
34text areinv "Invalid JSON-RPC request: object, jsonrpc 2.0, string method and string/integer id required"
35text arepar "Invalid params: strict named arguments required; document content limit is 65536 UTF-8 bytes"
36text aremeth "Method not found"
37text arcap "capabilities"
38text arlc "listChanged"
39text arsi "serverInfo"
40text arversio "version"
41text arserver "omega-agent-maintenance"
42text arvers "0.1.0"
43text arinst "instructions"
44text arhelp "Host-only saved-file maintenance, not active OMP runtime reload. Default read-only. Protected /srv/aien-keep store is always read-only. Validation checks syntax/structure only, not models, credentials, policy effectiveness or runtime compatibility. Proposals and rollback tokens are connection-scoped; retain the exact before-content preview for durable recovery."
45text ardesc "description"
46text arschema "inputSchema"
47text arprops "properties"
48text arreq "required"
49text aradd "additionalProperties"
50text arobj "object"
51text arstr "string"
52text armax "maxLength"
53text armin "minLength"
54text arpatter "pattern"
55text arhashpa "^[0-9a-f]{64}$"
56text arinv "inventory"
57text arread "read_file"
58text arval "validate"
59text arprop "propose"
60text arapply "apply"
61text arroll "rollback"
62text ard0 "Inventory supported saved agent files and per-file status, canonical root and read-only/writable mode. Does not report active runtime state."
63text ard1 "Read exact saved UTF-8 file bytes, byte size and SHA-256. Logical IDs only: RULES.md, WATCHDOG.yml, config.yml, agents/<safe-slug>.md."
64text ard2 "Validate syntax/structure only: JSON object for config/WATCHDOG, JSON-object markdown frontmatter for agent definitions; no semantic/runtime guarantee. Legacy YAML remains readable but is not validated here."
65text ard3 "Prepare one immutable connection-scoped proposal against an exact SHA-256, with full before/after preview and apply_allowed. No file write. Replaces the previous proposal; maximum document payload 65536 bytes."
66text ard4 "Apply the exact connection-scoped proposal once, requiring --allow-write and unchanged before hash. Protected store always refuses. Atomic saved-file update, not runtime reload."
67text ard5 "Restore the before bytes of the applied connection-scoped proposal once, only if current bytes still match after hash. Requires --allow-write; protected store refuses. Token/recovery state does not persist across disconnect."
68text arsummar "See structuredContent for the exact result, full document preview, and connection-scoped recovery details."
69text areinter "Internal error: storage result is not a complete JSON object"
70
71fn arwt ob edit uchar 787472 s view uchar * to void
72js_wsbuf ob s 0 len s
73end
74fn arpair ob edit uchar 787472 key view uchar * value view uchar * to void
75arwt ob key
76arwt ob value
77end
78fn armem src view uchar 524288 tape view uint 65536 obj ulong key view uchar * to ulong
79if ne js_type tape obj jsobj
80ret jsnone
81end
82k = js_first tape obj
83while ne k jsnone bound 999999
84if js_streq src js_off tape k key
85ret add k 1
86end
87k = js_mnext tape k
88end
89ret jsnone
90end
91fn arfull src view uchar * off ulong n ulong to bool
92p = ulong 0
93while lt p n bound 999999
94r = write 1 src add off p sub n p
95if eq r -4
96continue
97end
98if le r 0
99ret false
100end
101p = add p ulong r
102end
103ret true
104end
105fn arbegin src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void
106z = js_winit ob
107js_wobj ob
108arpair ob arj arver
109arwt ob arid
110t = get arrpc 0
111if eq t jsnone
112js_wnull ob
113else
114js_wtok ob src js_type tape t js_off tape t
115end
116end
117fn arsend ob edit uchar 787472 to void
118js_wobje ob
119n = js_wdone ob
120if lt n 0
121exit 5
122end
123ok = arfull ob 1040 ulong n
124if not ok
125exit 6
126end
127ok = arfull arnl 0 1
128if not ok
129exit 6
130end
131end
132fn arerror src view uchar 524288 tape view uint 65536 ob edit uchar 787472 code long msg view uchar * to void
133arbegin src tape ob
134arwt ob arerr
135js_wobj ob
136arwt ob arcode
137js_wlong ob code
138arpair ob armsg msg
139js_wobje ob
140arsend ob
141end
142fn arname ob edit uchar 787472 op ulong to void
143if eq op 0
144arwt ob arinv
145end
146if eq op 1
147arwt ob arread
148end
149if eq op 2
150arwt ob arval
151end
152if eq op 3
153arwt ob arprop
154end
155if eq op 4
156arwt ob arapply
157end
158if eq op 5
159arwt ob arroll
160end
161end
162fn ardescription ob edit uchar 787472 op ulong to void
163if eq op 0
164arwt ob ard0
165end
166if eq op 1
167arwt ob ard1
168end
169if eq op 2
170arwt ob ard2
171end
172if eq op 3
173arwt ob ard3
174end
175if eq op 4
176arwt ob ard4
177end
178if eq op 5
179arwt ob ard5
180end
181end
182fn arfield ob edit uchar 787472 key view uchar * cap ulong to void
183arwt ob key
184js_wobj ob
185arpair ob artype arstr
186arwt ob armax
187js_wulong ob cap
188if ne cap 65536
189arwt ob armin
190js_wulong ob 1
191end
192if eq cap 64
193arpair ob arpatter arhashpa
194end
195js_wobje ob
196end
197fn arschemawrite ob edit uchar 787472 op ulong to void
198js_wobj ob
199arwt ob arn
200arname ob op
201arwt ob ardesc
202ardescription ob op
203arwt ob arschema
204js_wobj ob
205arpair ob artype arobj
206arwt ob aradd
207js_wbool ob false
208arwt ob arprops
209js_wobj ob
210if and ge op 1 le op 3
211arfield ob arf 127
212end
213if or eq op 2 eq op 3
214arfield ob arc 65536
215end
216if eq op 3
217arfield ob arh 64
218end
219if ge op 4
220arfield ob art 128
221end
222js_wobje ob
223arwt ob arreq
224js_warr ob
225if and ge op 1 le op 3
226arwt ob arf
227end
228if or eq op 2 eq op 3
229arwt ob arc
230end
231if eq op 3
232arwt ob arh
233end
234if ge op 4
235arwt ob art
236end
237js_warre ob
238js_wobje ob
239js_wobje ob
240end
241fn arinitialize src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void
242p = get arrpc 1
243v = armem src tape p arpv
244if ne js_type tape v jsstr
245arerror src tape ob -32602 arepar
246ret
247end
248arbegin src tape ob
249arwt ob arres
250js_wobj ob
251arwt ob arpv
252if js_streq src js_off tape v arpv2
253arwt ob arpv2
254else
255if js_streq src js_off tape v arpv3
256arwt ob arpv3
257else
258arwt ob arpv1
259end
260end
261arwt ob arcap
262js_wobj ob
263arwt ob artools
264js_wobj ob
265arwt ob arlc
266js_wbool ob false
267js_wobje ob
268js_wobje ob
269arwt ob arsi
270js_wobj ob
271arpair ob arn arserver
272arpair ob arversio arvers
273js_wobje ob
274arpair ob arinst arhelp
275js_wobje ob
276arsend ob
277end
278fn artoolop src view uchar 524288 off ulong to ulong
279if js_streq src off arinv
280ret 0
281end
282if js_streq src off arread
283ret 1
284end
285if js_streq src off arval
286ret 2
287end
288if js_streq src off arprop
289ret 3
290end
291if js_streq src off arapply
292ret 4
293end
294if js_streq src off arroll
295ret 5
296end
297ret jsnone
298end
299note Exact field count plus required unique known fields refuses extras and duplicate keys.
300fn arargs src view uchar 524288 tape view uint 65536 a ulong op ulong to bool
301if ne js_type tape a jsobj
302ret false
303end
304want = ulong 0
305if eq op 1
306want = 1
307end
308if eq op 2
309want = 2
310end
311if eq op 3
312want = 3
313end
314if ge op 4
315want = 1
316end
317if ne js_nkids tape a want
318ret false
319end
320f = armem src tape a arf
321b = armem src tape a arc
322t = jsnone
323if eq op 3
324t = armem src tape a arh
325end
326if ge op 4
327t = armem src tape a art
328end
329if and ge op 1 le op 3
330if ne js_type tape f jsstr
331ret false
332end
333if or eq js_slen tape f 0 gt js_slen tape f 127
334ret false
335end
336end
337if or eq op 2 eq op 3
338if ne js_type tape b jsstr
339ret false
340end
341if gt js_slen tape b 65536
342ret false
343end
344end
345if ge op 3
346if ne js_type tape t jsstr
347ret false
348end
349if or eq js_slen tape t 0 gt js_slen tape t 128
350ret false
351end
352end
353put arrpc 3 f
354put arrpc 4 b
355put arrpc 5 t
356ret true
357end
358fn ardcopy ob edit uchar 787472 domain view uchar 787472 dt view uint 65536 n ulong to void
359for t ulong ulong get dt jshnt
360ty = js_type dt t
361off = js_off dt t
362js_wtok ob part domain 1040 n ty off
363end
364end
365
366note Storage owns a separate complete-object writer and may reset it on refusal.
367note Parse only after am_call returns; encoding failures must never rerun a mutation.
368fn ardomain src view uchar 524288 tape view uint 65536 ob edit uchar 787472 domain edit uchar 787472 dt edit uint 65536 to void
369n = js_wdone domain
370if le n 0
371arerror src tape ob -32603 areinter
372ret
373end
374z = js_init dt 786432 64
375if lt z 0
376arerror src tape ob -32603 areinter
377ret
378end
379r = js_parse part domain 1040 ulong n dt ulong n
380if lt r 0
381arerror src tape ob -32603 areinter
382ret
383end
384if ne js_type dt 0 jsobj
385arerror src tape ob -32603 areinter
386ret
387end
388arbegin src tape ob
389arwt ob arres
390js_wobj ob
391arwt ob arsc
392ardcopy ob domain dt ulong n
393arwt ob arc
394js_warr ob
395js_wobj ob
396arpair ob artype artext
397arpair ob artext arsummar
398js_wobje ob
399js_warre ob
400arwt ob ariserr
401js_wbool ob ne get amerror 0 0
402js_wobje ob
403arsend ob
404end
405fn arinvoke src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void
406file = new uchar 128 0
407body = new uchar 65536 0
408token = new uchar 128 0
409domain = new uchar 787472 0
410dt = new uint 65536 0
411nf = long 0
412nb = long 0
413nt = long 0
414if ne get arrpc 3 jsnone
415nf = js_sget src js_off tape get arrpc 3 file
416end
417if ne get arrpc 4 jsnone
418nb = js_sget src js_off tape get arrpc 4 body
419end
420if ne get arrpc 5 jsnone
421nt = js_sget src js_off tape get arrpc 5 token
422end
423if or lt nf 0 or lt nb 0 lt nt 0
424arerror src tape ob -32602 arepar
425ret
426end
427put amreq 0 ulong nf
428put amreq 1 ulong nb
429put amreq 2 ulong nt
430z = js_winit domain
431if lt z 0
432arerror src tape ob -32603 areinter
433ret
434end
435am_call get arrpc 2 file body token domain
436ardomain src tape ob domain dt
437end
438fn artoolcall src view uchar 524288 tape view uint 65536 ob edit uchar 787472 to void
439p = get arrpc 1
440if ne js_nkids tape p 2
441arerror src tape ob -32602 arepar
442ret
443end
444n = armem src tape p arn
445a = armem src tape p ara
446if ne js_type tape n jsstr
447arerror src tape ob -32602 arepar
448ret
449end
450op = artoolop src js_off tape n
451if eq op jsnone
452arerror src tape ob -32602 arepar
453ret
454end
455if not arargs src tape a op
456arerror src tape ob -32602 arepar
457ret
458end
459put arrpc 2 op
460arinvoke src tape ob
461end
462fn arhandle src view uchar 524288 tape edit uint 65536 ob edit uchar 787472 n ulong to void
463put arrpc 0 jsnone
464r = js_parse src tape n
465if lt r 0
466arerror src tape ob -32700 areparse
467ret
468end
469v = armem src tape 0 arj
470m = armem src tape 0 arm
471id = armem src tape 0 arid
472valid = eq js_type tape 0 jsobj
473if ne js_type tape v jsstr
474valid = false
475else
476if not js_streq src js_off tape v arver
477valid = false
478end
479end
480if ne js_type tape m jsstr
481valid = false
482end
483if ne id jsnone
484ty = js_type tape id
485if eq ty jsstr
486put arrpc 0 id
487else
488if eq ty jsnum
489if ne js_ilex src js_off tape id 0
490put arrpc 0 id
491else
492valid = false
493end
494else
495valid = false
496end
497end
498end
499note Duplicate envelope fields are ambiguous and cannot execute.
500if valid
501k = js_first tape 0
502seen = ulong 0
503while ne k jsnone bound 999999
504bit = ulong 0
505if js_streq src js_off tape k arj
506bit = 1
507end
508if js_streq src js_off tape k arm
509bit = 2
510end
511if js_streq src js_off tape k arid
512bit = 4
513end
514if js_streq src js_off tape k arp
515bit = 8
516end
517if ne and seen bit 0
518valid = false
519end
520seen = or seen bit
521k = js_mnext tape k
522end
523end
524if not valid
525arerror src tape ob -32600 areinv
526ret
527end
528note Valid notifications have neither response nor storage effects.
529if eq id jsnone
530ret
531end
532p = armem src tape 0 arp
533put arrpc 1 p
534if ne p jsnone
535if ne js_type tape p jsobj
536arerror src tape ob -32602 arepar
537ret
538end
539end
540if js_streq src js_off tape m arinit
541arinitialize src tape ob
542ret
543end
544if js_streq src js_off tape m arcall
545artoolcall src tape ob
546ret
547end
548if js_streq src js_off tape m arping
549arbegin src tape ob
550arwt ob arres
551js_wobj ob
552js_wobje ob
553arsend ob
554ret
555end
556if js_streq src js_off tape m arlist
557arbegin src tape ob
558arwt ob arres
559js_wobj ob
560arwt ob artools
561js_warr ob
562for op ulong 6
563arschemawrite ob op
564end
565js_warre ob
566js_wobje ob
567arsend ob
568ret
569end
570arerror src tape ob -32601 aremeth
571end
572fn arframe src view uchar 524288 tape edit uint 65536 ob edit uchar 787472 to void
573if ne get arrpc 7 0
574put arrpc 0 jsnone
575arerror src tape ob -32700 areparse
576else
577arhandle src tape ob get arrpc 6
578end
579put arrpc 6 0
580put arrpc 7 0
581end
582fn arfeed src edit uchar 524288 tape edit uint 65536 ob edit uchar 787472 chunk view uchar 4096 n ulong to void
583for i ulong n
584c = get chunk i
585if eq c 10
586arframe src tape ob
587else
588if eq get arrpc 7 0
589p = get arrpc 6
590if ge p len src
591put arrpc 7 1
592else
593put src p c
594put arrpc 6 add p 1
595end
596end
597end
598end
599end
600fn main to int
601src = new uchar 524288 0
602tape = new uint 65536 0
603ob = new uchar 787472 0
604chunk = new uchar 4096 0
605b = am_boot
606if ne b 0
607ret b
608end
609z = js_init tape 524288 64
610if lt z 0
611ret 4
612end
613note Each read consumes bytes or EOF; nested bounded epochs permit a long-lived stdio connection.
614for epoch ulong 999999
615for tick ulong 999999
616r = read 0 chunk 0 len chunk
617if eq r -4
618continue
619end
620if lt r 0
621ret 7
622end
623if eq r 0
624if or ne get arrpc 6 0 ne get arrpc 7 0
625arframe src tape ob
626end
627ret 0
628end
629arfeed src tape ob chunk ulong r
630end
631end
632ret 0
633end