@tjamescouch/gro 1.3.4 → 1.3.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tjamescouch/gro",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Provider-agnostic LLM runtime with context management",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/main.ts CHANGED
@@ -25,8 +25,9 @@ import type { ChatDriver, ChatMessage, ChatOutput, TokenUsage } from "./drivers/
25
25
  import type { AgentMemory } from "./memory/agent-memory.js";
26
26
  import { bashToolDefinition, executeBash } from "./tools/bash.js";
27
27
  import { agentpatchToolDefinition, executeAgentpatch } from "./tools/agentpatch.js";
28
+ import { groVersionToolDefinition, executeGroVersion, getGroVersion } from "./tools/version.js";
28
29
 
29
- const VERSION = "0.3.1";
30
+ const VERSION = getGroVersion();
30
31
 
31
32
  // ---------------------------------------------------------------------------
32
33
  // Graceful shutdown state — module-level so signal handlers can save sessions.
@@ -497,6 +498,7 @@ async function executeTurn(
497
498
  const tools = mcp.getToolDefinitions();
498
499
  tools.push(agentpatchToolDefinition());
499
500
  if (cfg.bash) tools.push(bashToolDefinition());
501
+ tools.push(groVersionToolDefinition());
500
502
  let finalText = "";
501
503
  let turnTokensIn = 0;
502
504
  let turnTokensOut = 0;
@@ -579,6 +581,8 @@ async function executeTurn(
579
581
  result = executeAgentpatch(fnArgs);
580
582
  } else if (fnName === "bash" && cfg.bash) {
581
583
  result = executeBash(fnArgs);
584
+ } else if (fnName === "gro_version") {
585
+ result = executeGroVersion({ provider: cfg.provider, model: cfg.model, persistent: cfg.persistent });
582
586
  } else {
583
587
  result = await mcp.callTool(fnName, fnArgs);
584
588
  }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Built-in version/identity tool for gro.
3
+ *
4
+ * Lets agents (and humans) introspect the gro runtime — version, provider,
5
+ * model, uptime, process info. This is the canonical way to confirm an
6
+ * agent is running on gro.
7
+ */
8
+ import { readFileSync, existsSync } from "node:fs";
9
+ import { join, dirname } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+
12
+ const startTime = Date.now();
13
+
14
+ interface GroRuntimeInfo {
15
+ runtime: "gro";
16
+ version: string;
17
+ provider: string;
18
+ model: string;
19
+ pid: number;
20
+ uptime_seconds: number;
21
+ node_version: string;
22
+ platform: string;
23
+ persistent: boolean;
24
+ }
25
+
26
+ /** Read version from package.json — single source of truth. */
27
+ function readVersion(): string {
28
+ // In ESM, __dirname isn't available — derive from import.meta.url
29
+ let selfDir: string;
30
+ try {
31
+ selfDir = dirname(fileURLToPath(import.meta.url));
32
+ } catch {
33
+ selfDir = process.cwd();
34
+ }
35
+
36
+ const candidates = [
37
+ join(selfDir, "..", "package.json"), // from dist/tools/ or src/tools/
38
+ join(selfDir, "..", "..", "package.json"), // from deeper nesting
39
+ join(process.cwd(), "package.json"),
40
+ ];
41
+ for (const p of candidates) {
42
+ if (existsSync(p)) {
43
+ try {
44
+ const pkg = JSON.parse(readFileSync(p, "utf-8"));
45
+ if (pkg.name === "@tjamescouch/gro" && pkg.version) {
46
+ return pkg.version;
47
+ }
48
+ } catch {
49
+ // try next candidate
50
+ }
51
+ }
52
+ }
53
+ return "unknown";
54
+ }
55
+
56
+ // Cache version at module load
57
+ const GRO_VERSION = readVersion();
58
+
59
+ export function getGroVersion(): string {
60
+ return GRO_VERSION;
61
+ }
62
+
63
+ export function groVersionToolDefinition(): any {
64
+ return {
65
+ type: "function",
66
+ function: {
67
+ name: "gro_version",
68
+ description:
69
+ "Report gro runtime identity and version. Returns runtime name, version, provider, model, uptime, and process info. Use this to confirm an agent is running on gro.",
70
+ parameters: {
71
+ type: "object",
72
+ properties: {},
73
+ },
74
+ },
75
+ };
76
+ }
77
+
78
+ /**
79
+ * Execute the version tool. Requires runtime config to report provider/model.
80
+ */
81
+ export function executeGroVersion(cfg: {
82
+ provider: string;
83
+ model: string;
84
+ persistent: boolean;
85
+ }): string {
86
+ const info: GroRuntimeInfo = {
87
+ runtime: "gro",
88
+ version: GRO_VERSION,
89
+ provider: cfg.provider,
90
+ model: cfg.model,
91
+ pid: process.pid,
92
+ uptime_seconds: Math.floor((Date.now() - startTime) / 1000),
93
+ node_version: process.version,
94
+ platform: process.platform,
95
+ persistent: cfg.persistent,
96
+ };
97
+ return JSON.stringify(info, null, 2);
98
+ }