lmgcp guide

Overview

lmgcp is a single-binary Google Cloud Platform host for LMScript built on lmcode-go and official Google Cloud Go SDKs (cloud.google.com/go and google.golang.org/api). It provides two execution surfaces in one executable: the native 16-service Gcp schema (default lmgcp command) and the provider-neutral lmcloud schema (lmgcp cloud subcommand).

Dual schema architecture: native Gcp and shared lmcloud

Understanding the two CLI modes lets you pick the right abstraction for your script:

In-process fakegcp server versus local gcpsim emulator

lmgcp supports three transport backends without code changes:

Cloud safety guardrails and RunLedger cost model

Every mutating operation in lmgcp passes through internal/safety guardrails:

Standard lmcode_std_v3 REST and CLI interfaces

Both native lmgcp and lmgcp cloud register the 226-signature lmcode_std_v3 standard library, including all 10 standard REST and CLI SAM interfaces (RestGet, RestPost, RestPut, RestDelete, RestPatch, RestHead, RestOptions, RestHandler, CliCommand, CliOption) and the 5 dispatcher functions (rest_config, rest_route, rest_serve, rest_stop, rest_cli).

p = _lmcode_ cli="lmgcp" install="github:lmctl-ai/lmgcp@latest";
  @"/projects/inventory/:service"
  fn get_inv(x: RestExchange) -> void implements RestGet {
    let svc = x.param("service");
    if (svc == "vms") {
      x.json("{\"vms\":" + str(gcp.compute_list_instances(gcp.zone()).len()) + "}");
      return;
    }
    x.json("{\"buckets\":" + str(gcp.storage_list_buckets().len()) + "}");
  }

  @"--format"
  fn opt_fmt(x: RestExchange) -> void implements CliOption {
    x.set("fmt", x.query("format"));
  }

  @"audit"
  fn cmd_audit(x: RestExchange) -> void implements CliCommand {
    x.send(x.get("fmt") + ":vms=" + str(gcp.compute_list_instances(gcp.zone()).len()));
  }

  rest_config("prefix", "/v1");
  let a = rest_cli(str_split("--format text audit", " "));
  let b = rest_cli(str_split("/v1/projects/inventory/vms", " "));
  print(a + " | " + b);
end _lmcode_