Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1.8 kB · 62 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263//// Traces are written by the tool path and read back through the session.
import albedo/harness/runtimeimport albedo/openai_api/typesimport gleam/dynamic/decodeimport gleam/jsonimport gleam/stringimport gleeunit/should
fn call(id: String, code: String) -> types.ToolCall { let arguments = json.object([ #("code", json.string(code)), #("timeout_ms", json.int(5000)), ]) |> json.to_string types.ToolCall(id, "python", arguments)}
fn value(output: String) -> String { let assert Ok(value) = json.parse(output, decode.field("value", decode.string, decode.success)) value}
pub fn a_cell_trace_is_readable_from_the_session_test() { let assert Ok(host) = runtime.start(":memory:") let assert Ok(session) = runtime.open_session(host, "a", "/tmp") let assert Ok(types.ToolOutput(_, written, _)) = runtime.invoke( host, session, call( "one", "import uuid\nfrom pathlib import Path\nPath('/tmp/albedo_trace_probe.txt').write_text(uuid.uuid4().hex)", ), ) written |> string.contains("\"status\":\"ok\"") |> should.be_true let assert Ok(types.ToolOutput(_, read, _)) = runtime.invoke( host, session, call( "two", "trace = await cells.trace('a/one')\n[change['path'] for change in trace['changes']]", ), ) value(read) |> should.equal("['/tmp/albedo_trace_probe.txt']") let assert Ok(types.ToolOutput(_, missing, _)) = runtime.invoke( host, session, call( "three", "try:\n await cells.trace('a/three')\nexcept Exception as error:\n print(error)", ), ) missing |> string.contains("recorded when the cell finishes") |> should.be_true runtime.stop(host)}