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.5 kB 56 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657//// Default extension wiring for standalone kernel tests.
import albedo/daemon/storeimport albedo/harness/extensions/python/jobsimport albedo/harness/extensions/python/kernel as pythonimport albedo/harness/extensions/work/ledger as workimport albedo/harness/extensions/work/rpcimport albedo/harness/rpc as harness_rpcimport albedo/harness/session_failureimport gleam/jsonimport gleam/result
pub fn local( ledger: store.Store, cwd: String,) -> Result(python.Kernel, python.Error) { use _ <- result.try( work.initialise(ledger) |> result.map_error(session_failure.Unavailable), ) python.local_with_plugins( ledger, cwd, fn(method, args) { rpc.handle(ledger, cwd, method, args) |> harness_rpc.reply }, ["run", "work"], )}
/// A kernel recorded as session `id`, with the jobs helper's route wired as/// the run extension wires it: a helper that appears gets its owner.pub fn session( ledger: store.Store, id: String, cwd: String,) -> Result(python.Kernel, python.Error) { use _ <- result.try( work.initialise(ledger) |> result.map_error(session_failure.Unavailable), ) python.open( ledger, id, cwd, fn(method, args) { case method { "jobs.attached" -> { jobs.ensure(ledger, id) harness_rpc.reply(Ok(json.string("attached"))) } _ -> rpc.handle(ledger, cwd, method, args) |> harness_rpc.reply } }, ["run", "work"], ) |> result.map(fn(opened) { opened.0 })}