code wiki / (root) / nx_tool_registry.nx

nx_tool_registry.nx source

↩ module page · 24 lines · 1669 B

1// nx_tool_registry.nx -- MCP Tools-primitive parity, sovereign: every Nishi organ/capability registers itself 2// (name / description / how-to-invoke / gate-status) and is DISCOVERABLE. Backed by the canonical nx_registry on 3// seg_store (additive, history kept). The registry IS the capability list the census measures -> one source of truth. 4// Record (tab-separated): name <TAB> description <TAB> invoke <TAB> status. license_tier: ORIGINAL 5import "nx_registry.nx" 6import "nx_tabrec.nx" 7const TOOL_MAGIC_2048: i64 = 2048 8 9const TOOL_KP: *u8 = "tool:" as *u8 10const TOOL_IDX: *u8 = "__toolidx__" as *u8 11const TOOL_PREFIX: *u8 = "knowledge/toolreg-" as *u8 12 13func tool_register_pfx(prefix: *u8, name: *u8, desc: *u8, invoke: *u8, status: *u8) -> i64 { 14 let rec: *u8 = sys_mmap(TOOL_MAGIC_2048); var o: i64=0 15 o=tr_cat(rec,o,name); o=tr_tab(rec,o); o=tr_cat(rec,o,desc); o=tr_tab(rec,o); o=tr_cat(rec,o,invoke); o=tr_tab(rec,o); o=tr_cat(rec,o,status) 16 return reg_put(prefix, TOOL_KP, TOOL_IDX, name, rec, o) 17} 18func tool_get_pfx(prefix: *u8, name: *u8, ptrout: *i64, lenout: *i64) -> i64 { return reg_get(prefix, TOOL_KP, name, ptrout, lenout) } 19func tool_list_pfx(prefix: *u8, idxbuf: *u8, cap: i64) -> i64 { return reg_index(prefix, TOOL_IDX, idxbuf, cap) } 20 21// production-prefix convenience wrappers 22func tool_register(name: *u8, desc: *u8, invoke: *u8, status: *u8) -> i64 { return tool_register_pfx(TOOL_PREFIX, name, desc, invoke, status) } 23func tool_get(name: *u8, ptrout: *i64, lenout: *i64) -> i64 { return tool_get_pfx(TOOL_PREFIX, name, ptrout, lenout) } 24func tool_list(idxbuf: *u8, cap: i64) -> i64 { return tool_list_pfx(TOOL_PREFIX, idxbuf, cap) }