@lmctl-ai/lmctl 0.2.109 → 0.2.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -556,6 +556,42 @@ CREATE VIEW IF NOT EXISTS turn_usage AS SELECT
556
556
  +COALESCE(tok_output,0)*COALESCE(rate_output_1m,0))/1e6 END AS cost_usd
557
557
  FROM team_chat_log WHERE attempt_key IS NOT NULL;
558
558
 
559
+ CREATE TABLE IF NOT EXISTS price_snapshot (
560
+ sha256 TEXT PRIMARY KEY,
561
+ generated_at TEXT,
562
+ source TEXT NOT NULL,
563
+ fetched_at TEXT NOT NULL,
564
+ loaded_at TEXT NOT NULL,
565
+ record_count INTEGER NOT NULL,
566
+ standards_json TEXT NOT NULL CHECK(json_valid(standards_json))
567
+ );
568
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_price_snapshot_singleton ON price_snapshot((1));
569
+
570
+ CREATE TABLE IF NOT EXISTS price_record (
571
+ record_id TEXT PRIMARY KEY,
572
+ source TEXT,
573
+ provider TEXT,
574
+ source_model_id TEXT,
575
+ vendor_model_id TEXT,
576
+ canonical_slug TEXT,
577
+ currency TEXT,
578
+ unit TEXT,
579
+ input_1m REAL,
580
+ output_1m REAL,
581
+ cache_read_1m REAL,
582
+ cache_write_1m REAL,
583
+ source_cost_fields TEXT CHECK(json_valid(source_cost_fields)),
584
+ record_json TEXT NOT NULL CHECK(json_valid(record_json)),
585
+ ordinal INTEGER NOT NULL
586
+ );
587
+
588
+ CREATE TABLE IF NOT EXISTS price_alias (
589
+ alias TEXT PRIMARY KEY,
590
+ standard_slug TEXT,
591
+ evidence TEXT,
592
+ catalog_record_id TEXT
593
+ );
594
+
559
595
  CREATE INDEX IF NOT EXISTS idx_team_chat_log_root_time
560
596
  ON team_chat_log(root_teamfile, created_at);
561
597
 
@@ -4,31 +4,29 @@
4
4
  # import them. The engine owns lmctl's own internals as host functions; everything external is
5
5
  # user space -- the same pattern applies to gh, aws, or any other CLI a script wants to wrap.
6
6
 
7
- # NOTE: system() goes through a SHELL and there is no quoting helper, so any subcmd containing
8
- # | & ; < > $ ` must be quoted by the caller. The failure mode is an EMPTY result, not an error --
9
- # `--pretty=format:%h|%s` silently pipes into `%s` and returns "".
10
- # NOTE: system() returns [stdout, stderr] and NO exit status, so these wrappers cannot distinguish
11
- # "command failed" from "command succeeded with no output".
7
+ # Argv stays structured; failures name git and include its stderr.
12
8
  fn git_run(repo, subcmd) {
13
- out = system(format("git -C {0} {1} 2>/dev/null", repo, subcmd));
9
+ out = system(concat(["git", "-C", repo], subcmd));
10
+ if (out.code != 0) { require(false, "git failed (" + str(out.code) + "): " + out.stderr); }
14
11
  return trim(out.stdout);
15
12
  }
16
13
 
17
14
  fn is_git_repo(path) {
18
15
  if (!file_exists(path)) { return false; }
19
- return git_run(path, "rev-parse --is-inside-work-tree") == "true";
16
+ r = system(["git","-C",path,"rev-parse","--is-inside-work-tree"]);
17
+ return r.code == 0 && trim(r.stdout) == "true";
20
18
  }
21
19
 
22
20
  fn git_head(repo) {
23
- return git_run(repo, "log -1 --format=%H");
21
+ return git_run(repo, ["log", "-1", "--format=%H"]);
24
22
  }
25
23
 
26
24
  fn git_head_short(repo) {
27
- return git_run(repo, "log -1 --pretty=format:%h|%s"); # no space: git_run does not quote
25
+ return git_run(repo, ["log", "-1", "--pretty=format:%h|%s"]); # format is one argv element
28
26
  }
29
27
 
30
28
  fn git_head_epoch(repo) {
31
- s = git_run(repo, "log -1 --format=%ct");
29
+ s = git_run(repo, ["log", "-1", "--format=%ct"]);
32
30
  if (len(s) == 0) { return 0; }
33
31
  return num(s);
34
32
  }
@@ -36,7 +34,7 @@ fn git_head_epoch(repo) {
36
34
  # Changed = tracked-but-modified. Untracked = new and unignored. Kept separate on purpose:
37
35
  # conflating them is how "the tree is dirty" stops telling you WHICH kind of dirty.
38
36
  fn git_changed(repo) {
39
- lines = split(git_run(repo, "status --porcelain"), "\n");
37
+ lines = split(git_run(repo, ["status", "--porcelain"]), "\n");
40
38
  changed = [];
41
39
  i = 0;
42
40
  while (i < len(lines)) {
@@ -48,7 +46,7 @@ fn git_changed(repo) {
48
46
  }
49
47
 
50
48
  fn git_untracked(repo) {
51
- lines = split(git_run(repo, "status --porcelain"), "\n");
49
+ lines = split(git_run(repo, ["status", "--porcelain"]), "\n");
52
50
  untracked = [];
53
51
  i = 0;
54
52
  while (i < len(lines)) {
@@ -61,9 +59,9 @@ fn git_untracked(repo) {
61
59
  fn git_unpushed(repo) {
62
60
  # No upstream is NOT an error -- a worktree branch deliberately has none.
63
61
  # NOTE: "@{u}" cannot go through format() -- "{u}" is read as a format placeholder.
64
- up = system("git -C " + repo + " rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null");
62
+ up = system(["git","-C",repo,"rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"]);
65
63
  if (len(trim(up.stdout)) == 0) { return -1; } # -1 = no upstream, distinct from 0 = nothing to push
66
- n = trim(system("git -C " + repo + " rev-list --count @{u}..HEAD 2>/dev/null").stdout);
64
+ n = trim(system(["git","-C",repo,"rev-list","--count","@{u}..HEAD"]).stdout);
67
65
  if (len(n) == 0) { return -1; }
68
66
  return num(n);
69
67
  }
@@ -71,7 +69,7 @@ fn git_unpushed(repo) {
71
69
  # "Are these changes AFTER some LLM process?" -- compare the working tree's newest mtime against a
72
70
  # marker time (e.g. when an agent turn started).
73
71
  fn touched_since(repo, epoch) {
74
- out = system(format("git -C {0} status --porcelain", repo));
72
+ out = system(["git","-C",repo,"status","--porcelain"]);
75
73
  lines = split(trim(out.stdout), "\n");
76
74
  recent = [];
77
75
  i = 0;
@@ -80,7 +78,7 @@ fn touched_since(repo, epoch) {
80
78
  if (len(l) == 0) { continue; }
81
79
  parts = split(l, " ");
82
80
  f = parts[len(parts) - 1];
83
- st = system(format("stat -c %Y {0}/{1} 2>/dev/null", repo, f));
81
+ st = system(["stat","-c","%Y",path_join(repo,f)]);
84
82
  m = trim(st.stdout);
85
83
  if (len(m) > 0 && num(m) >= epoch) { push(recent, f); }
86
84
  }
@@ -9,18 +9,18 @@ import "./agent-lib.lms";
9
9
  # --- External Service Wrappers over system() ---
10
10
 
11
11
  fn curl_fetch_json(url) {
12
- cmd = format("curl -s -m 10 \"{0}\"", url);
13
- out = system(cmd);
14
- if (out[2] != 0 || len(trim(out[0])) == 0) {
12
+ argv = ["curl","-s","-m","10",url];
13
+ out = system(argv);
14
+ if (out.code != 0 || len(trim(out.stdout)) == 0) {
15
15
  return null;
16
16
  }
17
- return json_parse(trim(out[0]));
17
+ return json_parse(trim(out.stdout));
18
18
  }
19
19
 
20
20
  fn curl_post_webhook(url, body_json) {
21
- cmd = format("curl -s -o /dev/null -w \"%{http_code}\" -m 10 -X POST -H \"Content-Type: application/json\" -d '{0}' \"{1}\"", body_json, url);
22
- out = system(cmd);
23
- return trim(out[0]);
21
+ argv = ["curl","-s","-o","/dev/null","-w","%{http_code}","-m","10","-X","POST","-H","Content-Type: application/json","-d",body_json,url];
22
+ out = system(argv);
23
+ return trim(out.stdout);
24
24
  }
25
25
 
26
26
  # --- Main Script ---
@@ -16,14 +16,14 @@ fn curl_get_openai_embedding(text, api_key) {
16
16
  "input": text,
17
17
  "model": "text-embedding-3-small"
18
18
  });
19
- cmd = format("curl -s https://api.openai.com/v1/embeddings -H \"Authorization: Bearer {0}\" -H \"Content-Type: application/json\" -d '{1}'", api_key, payload);
20
- out = system(cmd, 15000);
21
- if (out[2] != 0 || len(trim(out[0])) == 0) {
22
- return { "error": "CURL_FAILED", "details": trim(out[1]), "vector": [] };
19
+ argv = ["curl","-s","https://api.openai.com/v1/embeddings","-H","Authorization: Bearer "+api_key,"-H","Content-Type: application/json","-d",payload];
20
+ out = system(argv, 15000);
21
+ if (out.code != 0 || len(trim(out.stdout)) == 0) {
22
+ return { "error": "CURL_FAILED", "details": trim(out.stderr), "vector": [] };
23
23
  }
24
- res = json_parse(trim(out[0]));
24
+ res = json_parse(trim(out.stdout));
25
25
  if (res == null || !has_key(res, "data")) {
26
- return { "error": "API_ERROR", "details": trim(out[0]), "vector": [] };
26
+ return { "error": "API_ERROR", "details": trim(out.stdout), "vector": [] };
27
27
  }
28
28
  return { "error": null, "vector": res.data[0].embedding };
29
29
  }
@@ -66,7 +66,7 @@ if (len(args) > 1) { alias = args[1]; }
66
66
 
67
67
  # Check for API key in environment
68
68
  api_key = "";
69
- env_key = system("echo -n \"$OPENAI_API_KEY\"");
69
+ env_key = {stdout: env("OPENAI_API_KEY", "")};
70
70
  if (len(trim(env_key[0])) > 0) {
71
71
  api_key = trim(env_key[0]);
72
72
  }
@@ -9,24 +9,24 @@ import "./agent-lib.lms";
9
9
  # --- External Tool Wrappers over system() ---
10
10
 
11
11
  fn tool_sqlite_query(db_path, sql) {
12
- cmd = format("sqlite3 -batch -json \"{0}\" \"{1}\" 2>&1", db_path, sql);
13
- out = system(cmd);
14
- if (out[2] != 0) {
15
- return "Error executing query: " + trim(out[1]);
12
+ argv = ["sqlite3","-batch","-json",db_path,sql];
13
+ out = system(argv);
14
+ if (out.code != 0) {
15
+ return "Error executing query: " + trim(out.stderr);
16
16
  }
17
- return trim(out[0]);
17
+ return trim(out.stdout);
18
18
  }
19
19
 
20
20
  fn tool_search_kb(keyword, doc_dir) {
21
- cmd = format("grep -rn -i -m 5 \"{0}\" \"{1}\" 2>/dev/null", keyword, doc_dir);
22
- out = system(cmd);
23
- return trim(out[0]);
21
+ argv = ["grep","-rn","-i","-m","5","--",keyword,doc_dir];
22
+ out = system(argv);
23
+ return trim(out.stdout);
24
24
  }
25
25
 
26
26
  fn tool_http_ping(host) {
27
- cmd = format("curl -s -o /dev/null -w \"%{http_code}\" --connect-timeout 2 \"{0}\"", host);
28
- out = system(cmd);
29
- return trim(out[0]);
27
+ argv = ["curl","-s","-o","/dev/null","-w","%{http_code}","--connect-timeout","2",host];
28
+ out = system(argv);
29
+ return trim(out.stdout);
30
30
  }
31
31
 
32
32
  # --- Setup Mock Environment for the Agent's Tools ---
@@ -36,7 +36,7 @@ mock_db = "examples/n8n/mock-support.db";
36
36
  init_sql = "CREATE TABLE IF NOT EXISTS orders (order_id TEXT PRIMARY KEY, customer_id TEXT, status TEXT, total REAL, item TEXT);" +
37
37
  "INSERT OR REPLACE INTO orders VALUES ('ORD-9021', 'CUST-104', 'Shipped - In Transit', 85.00, 'Mechanical Keyboard');" +
38
38
  "INSERT OR REPLACE INTO orders VALUES ('ORD-9022', 'CUST-208', 'Pending Fulfillment', 24.50, 'USB-C Cable Pack');";
39
- system(format("sqlite3 \"{0}\" \"{1}\"", mock_db, init_sql));
39
+ system(["sqlite3",mock_db,init_sql]);
40
40
 
41
41
  # --- Main Script ---
42
42
 
@@ -9,15 +9,15 @@ import "./agent-lib.lms";
9
9
  # --- External Service Wrappers over system() ---
10
10
 
11
11
  fn gh_create_issue(repo, title, body, label) {
12
- cmd = format("gh issue create -R \"{0}\" --title \"{1}\" --body \"{2}\" --label \"{3}\" 2>&1", repo, title, body, label);
13
- out = system(cmd);
14
- return [out[2], trim(out[0])];
12
+ argv = ["gh","issue","create","-R",repo,"--title",title,"--body",body,"--label",label];
13
+ out = system(argv);
14
+ return [out.code, trim(out.stdout)];
15
15
  }
16
16
 
17
17
  fn post_webhook(url, payload_json) {
18
- cmd = format("curl -s -o /dev/null -w \"%{http_code}\" -X POST -H \"Content-Type: application/json\" -d '{0}' \"{1}\"", payload_json, url);
19
- out = system(cmd);
20
- return trim(out[0]);
18
+ argv = ["curl","-s","-o","/dev/null","-w","%{http_code}","-X","POST","-H","Content-Type: application/json","-d",payload_json,url];
19
+ out = system(argv);
20
+ return trim(out.stdout);
21
21
  }
22
22
 
23
23
  fn append_triage_log(log_path, record_json) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmctl-ai/lmctl",
3
- "version": "0.2.109",
3
+ "version": "0.2.111",
4
4
  "description": "A provider-agnostic control plane for teams of AI coding agents — across providers, with independent review and durable memory.",
5
5
  "type": "module",
6
6
  "homepage": "https://lmctl.com",