opencode-heartbeat-approval 0.3.1 → 0.4.0

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/dist/index.js CHANGED
@@ -10,11 +10,6 @@ var __export = (target, all) => {
10
10
  });
11
11
  };
12
12
 
13
- // src/plugin.ts
14
- import { readFile } from "fs/promises";
15
- import { join } from "path";
16
- import { homedir } from "os";
17
-
18
13
  // node_modules/zod/v4/classic/external.js
19
14
  var exports_external = {};
20
15
  __export(exports_external, {
@@ -12338,20 +12333,6 @@ tool.schema = exports_external;
12338
12333
  // src/plugin.ts
12339
12334
  var POLL_INTERVAL_MS = 1e4;
12340
12335
  var JSON_HEADERS = { "Content-Type": "application/json" };
12341
- var SESSION_MAP_PATH = join(homedir(), ".config", "opencode", "heartbeat", "session-map.json");
12342
- async function lookupSessionMapping(sessionId) {
12343
- try {
12344
- const text = await readFile(SESSION_MAP_PATH, "utf-8");
12345
- const mapping = JSON.parse(text);
12346
- const entry = mapping[sessionId];
12347
- if (entry && typeof entry.port === "number" && entry.port > 0 && entry.port < 65536) {
12348
- return `http://127.0.0.1:${entry.port}`;
12349
- }
12350
- return null;
12351
- } catch {
12352
- return null;
12353
- }
12354
- }
12355
12336
  async function createGate(runnerUrl, params) {
12356
12337
  const resp = await fetch(`${runnerUrl}/api/approval`, {
12357
12338
  method: "POST",
@@ -12424,14 +12405,12 @@ Returns: { status: "approved" | "rejected" | "expired" | "unavailable" | "cancel
12424
12405
  let resolvedUrl = null;
12425
12406
  if (envPort && /^\d+$/.test(envPort)) {
12426
12407
  resolvedUrl = `http://127.0.0.1:${envPort}`;
12427
- } else {
12428
- resolvedUrl = await lookupSessionMapping(ctx.sessionID);
12429
12408
  }
12430
12409
  if (!resolvedUrl) {
12431
12410
  return JSON.stringify({
12432
12411
  status: "unavailable",
12433
12412
  type: requestType,
12434
- error: `No approval server found for session ${ctx.sessionID}. Ensure heartbeat runner is running for this role.`,
12413
+ error: "APPROVAL_PORT environment variable not set. Ensure this opencode serve instance has APPROVAL_PORT configured.",
12435
12414
  approval_id: null
12436
12415
  });
12437
12416
  }
package/dist/plugin.js CHANGED
@@ -10,11 +10,6 @@ var __export = (target, all) => {
10
10
  });
11
11
  };
12
12
 
13
- // src/plugin.ts
14
- import { readFile } from "fs/promises";
15
- import { join } from "path";
16
- import { homedir } from "os";
17
-
18
13
  // node_modules/zod/v4/classic/external.js
19
14
  var exports_external = {};
20
15
  __export(exports_external, {
@@ -12338,20 +12333,6 @@ tool.schema = exports_external;
12338
12333
  // src/plugin.ts
12339
12334
  var POLL_INTERVAL_MS = 1e4;
12340
12335
  var JSON_HEADERS = { "Content-Type": "application/json" };
12341
- var SESSION_MAP_PATH = join(homedir(), ".config", "opencode", "heartbeat", "session-map.json");
12342
- async function lookupSessionMapping(sessionId) {
12343
- try {
12344
- const text = await readFile(SESSION_MAP_PATH, "utf-8");
12345
- const mapping = JSON.parse(text);
12346
- const entry = mapping[sessionId];
12347
- if (entry && typeof entry.port === "number" && entry.port > 0 && entry.port < 65536) {
12348
- return `http://127.0.0.1:${entry.port}`;
12349
- }
12350
- return null;
12351
- } catch {
12352
- return null;
12353
- }
12354
- }
12355
12336
  async function createGate(runnerUrl, params) {
12356
12337
  const resp = await fetch(`${runnerUrl}/api/approval`, {
12357
12338
  method: "POST",
@@ -12424,14 +12405,12 @@ Returns: { status: "approved" | "rejected" | "expired" | "unavailable" | "cancel
12424
12405
  let resolvedUrl = null;
12425
12406
  if (envPort && /^\d+$/.test(envPort)) {
12426
12407
  resolvedUrl = `http://127.0.0.1:${envPort}`;
12427
- } else {
12428
- resolvedUrl = await lookupSessionMapping(ctx.sessionID);
12429
12408
  }
12430
12409
  if (!resolvedUrl) {
12431
12410
  return JSON.stringify({
12432
12411
  status: "unavailable",
12433
12412
  type: requestType,
12434
- error: `No approval server found for session ${ctx.sessionID}. Ensure heartbeat runner is running for this role.`,
12413
+ error: "APPROVAL_PORT environment variable not set. Ensure this opencode serve instance has APPROVAL_PORT configured.",
12435
12414
  approval_id: null
12436
12415
  });
12437
12416
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-heartbeat-approval",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "OpenCode plugin providing request_human_input MCP tool for Heartbeat pipeline (approval + assistance)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/plugin.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { homedir } from "node:os";
4
1
  import { tool } from "@opencode-ai/plugin";
5
2
  import type { PluginInput } from "@opencode-ai/plugin";
6
3
 
@@ -27,22 +24,6 @@ interface ConflictResponse {
27
24
  existing_approval_id: string;
28
25
  }
29
26
 
30
- const SESSION_MAP_PATH = join(homedir(), ".config", "opencode", "heartbeat", "session-map.json");
31
-
32
- async function lookupSessionMapping(sessionId: string): Promise<string | null> {
33
- try {
34
- const text = await readFile(SESSION_MAP_PATH, "utf-8");
35
- const mapping = JSON.parse(text) as Record<string, { port: number; role: string; created_at: string }>;
36
- const entry = mapping[sessionId];
37
- if (entry && typeof entry.port === "number" && entry.port > 0 && entry.port < 65536) {
38
- return `http://127.0.0.1:${entry.port}`;
39
- }
40
- return null;
41
- } catch {
42
- return null;
43
- }
44
- }
45
-
46
27
  async function createGate(runnerUrl: string, params: {
47
28
  prompt: string;
48
29
  artifacts?: string[];
@@ -132,14 +113,12 @@ Returns: { status: "approved" | "rejected" | "expired" | "unavailable" | "cancel
132
113
  let resolvedUrl: string | null = null;
133
114
  if (envPort && /^\d+$/.test(envPort)) {
134
115
  resolvedUrl = `http://127.0.0.1:${envPort}`;
135
- } else {
136
- resolvedUrl = await lookupSessionMapping(ctx.sessionID);
137
116
  }
138
117
  if (!resolvedUrl) {
139
118
  return JSON.stringify({
140
119
  status: "unavailable",
141
120
  type: requestType,
142
- error: `No approval server found for session ${ctx.sessionID}. Ensure heartbeat runner is running for this role.`,
121
+ error: "APPROVAL_PORT environment variable not set. Ensure this opencode serve instance has APPROVAL_PORT configured.",
143
122
  approval_id: null,
144
123
  });
145
124
  }