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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- vendored from evalframe v0.4.0 (~/.algocline/packages/evalframe/std.lua)
-- DO NOT EDIT here — upstream sync via manual copy
--[[
std.lua — stdlib adapter
Host (Rust) injects mlua-batteries as the `std` global table.
This module adapts batteries' API to evalframe's internal contract.
Contract (required):
std.json.decode(str) → table
std.json.encode(tbl) → string
std.fs.read_file(path) → string
std.fs.file_exists(path) → boolean
std.time() → number (epoch seconds)
Contract (optional):
std.http — passthrough from batteries
Boundary:
Security (path traversal, sandboxing) is enforced by batteries' Rust
implementation via PathPolicy. No Lua-side guards needed.
]]
local batteries = rawget
if not batteries
local M =
-- ============================================================
-- json — direct passthrough (required)
-- ============================================================
if not batteries.
M. = batteries.
-- ============================================================
-- fs — adapt batteries API names to evalframe contract (required)
--
-- batteries: read(path), is_file(path)
-- evalframe: read_file(path), file_exists(path)
-- ============================================================
if not batteries.
M. =
-- ============================================================
-- time — adapt from table to callable (required)
--
-- batteries: std.time.now() → epoch seconds (f64)
-- evalframe: std.time() → epoch seconds
-- ============================================================
if not
M. = batteries..
-- ============================================================
-- http — passthrough (optional)
-- ============================================================
if batteries.
return M