1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! The hook runtime: the Lua file every hook command runs through.
//!
//! # Responsibilities
//!
//! - [`RUNTIME_FILE`]: the runtime's file name under the extension root.
//! - [`RUNTIME_LUA`]: the runtime's text, compiled into the library.
/// The runtime's file name under the extension root.
pub const RUNTIME_FILE: &str = "runtime.lua";
/// The text of the hook runtime, as written to `<root>/runtime.lua`.
///
/// The runtime loads the extension's `translate` module and reads the hook module's name, the
/// `may_block` flag and the hook's kind from the command line's first three arguments; the rest are
/// the hook's own. For a neutral hook it builds a neutral event from the payload the tool sends and
/// stays silent when the translator has no event for it; for a native hook the event holds the raw
/// payload. It then runs the hook module. A `block` from a hook not declared `may_block` is dropped
/// with one line on standard error, and the translator's `result` is printed; it receives the hook's
/// result and the raw payload, for neutral and native hooks alike.
///
/// # Examples
///
/// ```
/// use agentstacks::types::protocol::RUNTIME_LUA;
///
/// assert!(RUNTIME_LUA.starts_with("-- agentstacks hook runtime"));
/// ```
pub const RUNTIME_LUA: &str = include_str!;