gitoriaLog in with ident

antcolony

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc613d26bc613d26btemplates: bridges to external components (login.js for ident's selector) are allowed (creator 2026-09-27)mrec613d26b/plugins/proc/server.hl

3.8 KB

  1. \* hl:proc — child processes as INSTANCE EVENTS.
  2. let server = spawn('llama-server -m ' + model + ' --port 8480')
  3. on server.line({ line, stream }) { … } \\ stream: 'stdout' | 'stderr'
  4. on server.exit({ exit, pid }) { … } \\ always arrives, kill or not
  5. server.kill() \\ SIGTERM; exit still fires
  6. `stream` names the PIPE, not a verdict — most servers (llama.cpp included)
  7. write their whole LOG to stderr, keeping stdout for data.
  8. A command that CANNOT START has no exit — it is an ERROR: caught by
  9. `on server.Error(e)` (this instance) or the global `on Error(e)`; uncaught
  10. it is a located crash naming the binary and the errno. A finished child
  11. retires its event source, so a program whose children are done simply ends.
  12. THE PROGRAM PATH follows the Hybriel path rule: `spawn('bin/llama-server …')`
  13. resolves bin/ against THIS SCRIPT's directory (like imports and hl:fs) — a
  14. copied build folder next to your .hl file just works. A bare name searches
  15. PATH; absolute stays absolute.
  16. There is NO SHELL — no quoting, no expansion (the safety property, not a
  17. gap). `spawnArgs([ 'sh', '-c', pipeline ])` is how you ASK for one,
  18. explicitly. *\
  19. /* Gate file (docs campaign): __native lives only here; the Process class
  20. (process.hl) carries the instance events and their declarations. */
  21. \* Start a child from ONE command string: split on WHITESPACE RUNS (spaces,
  22. tabs AND newlines — a command written across lines is one command); a
  23. quoted argument is GROUPED and its quotes stripped ('{"a": 1}' arrives as
  24. one argv entry). A command that cannot start is an Error — caught by
  25. `on server.Error(e)` or the global `on Error(e)`. *\
  26. spawn(
  27. String cmd \\ the program and its arguments, whitespace-separated
  28. ) {
  29. return new Process().start(cmd)
  30. }
  31. \* The LIST form — argv exactly as given: for arguments that contain spaces,
  32. or to ask for a shell explicitly: spawnArgs([ 'sh', '-c', pipeline ]). *\
  33. spawnArgs(
  34. Hybrid args \\ argv entries, one string each — args[0] is the program
  35. ) {
  36. return new Process().startArgs(args)
  37. }
  38. \* The terminal's own input as instance events — `input = stdin()`, then
  39. `on input.line(text)` per typed line and `on input.eof()` at Ctrl-D. A joined
  40. terminal realm (SPEC "Joining a realm") reads its keyboard here. *\
  41. stdin() {
  42. return new Stdin().start()
  43. }
  44. \* One environment variable, null when unset. The runtime loads a `.env`
  45. beside the project's entry BEFORE anything runs (KEY=VALUE lines, #
  46. comments; the real environment always wins), so env('OPENROUTER_KEY')
  47. reads either source through one call. *\
  48. env(
  49. String name \\ the variable's name
  50. ) {
  51. return __native("proc.env", name)
  52. }
  53. \* THE PROGRAM'S OWN ARGUMENTS (mission 317) — the strings that follow the
  54. entry on the command line, in order, as a list; an empty list when there
  55. were none.
  56. hybriel lex.hl a b // args() is ['a', 'b']
  57. ./lex a b // the compiled binary answers the same
  58. A project DIRECTORY entry is unchanged: `hybriel <projectDir> <realm>` still
  59. JOINS that realm, so the positional there is the realm's name and never an
  60. argument (SPEC "Joining a realm").
  61. Built here rather than handed over whole because a `__native` call answers
  62. with ONE value and a list is what the caller wants: the count and the i-th
  63. argument are the two questions the runtime can answer, and the list is the
  64. language's own. *\
  65. args() {
  66. let out = []
  67. let n = __native("proc.argc")
  68. let i = 0
  69. while (i < n) {
  70. out.push(__native("proc.arg", i))
  71. i = i + 1
  72. }
  73. return out
  74. }
  75. \* The process's current working directory, absolute — where the USER
  76. launched from. Your own files resolve script-relatively everywhere
  77. (imports, hl:fs, spawn); cwd() is for tools whose subject is the caller's
  78. directory: a formatter, a scaffolder. *\
  79. cwd() {
  80. return __native("proc.cwd")
  81. }

Branches

Latest commits

  • c613d26btemplates: bridges to external components (login.js for ident's selector) are allowed (creator 2026-09-27)mre
  • 9062978ctracker: worker box sees /media/STORAGE/projects/old-tracker read-only (tracker#2 source data)mre
  • 7f9660eeState of 2026-09-27, before the move to gitoriamre