@pushary/agent-hooks 0.4.1 → 0.4.3

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.
@@ -102,7 +102,11 @@ var main = async () => {
102
102
  });
103
103
  check(initRes.ok, "MCP server reachable", `${initRes.status} ${initRes.statusText}`);
104
104
  sessionId = initRes.headers.get("mcp-session-id") ?? "";
105
- check(!!sessionId, "Session ID returned", sessionId ? `${sessionId.slice(0, 8)}...` : "missing \u2014 update MCP SDK");
105
+ if (sessionId) {
106
+ console.log(` ${pass} Session ID returned ${dim(`(${sessionId.slice(0, 8)}...)`)}`);
107
+ } else {
108
+ console.log(` ${dim("\u2013")} Stateless mode ${dim("(no session ID)")}`);
109
+ }
106
110
  const initBody = await initRes.text();
107
111
  const initMatch = initBody.match(/data: (.+)/);
108
112
  if (initMatch) {
@@ -126,12 +130,21 @@ var main = async () => {
126
130
  signal: AbortSignal.timeout(1e4)
127
131
  });
128
132
  const toolsBody = await toolsRes.text();
129
- const toolsMatch = toolsBody.match(/data: (.+)/);
130
- if (toolsMatch) {
131
- const toolsData = JSON.parse(toolsMatch[1]);
132
- toolCount = toolsData.result?.tools?.length ?? 0;
133
+ if (!toolsRes.ok) {
134
+ try {
135
+ const errData = JSON.parse(toolsBody);
136
+ check(false, "MCP tools discovered", `${toolsRes.status}: ${errData.error?.message ?? toolsBody}`);
137
+ } catch {
138
+ check(false, "MCP tools discovered", `${toolsRes.status} ${toolsRes.statusText}`);
139
+ }
140
+ } else {
141
+ const toolsMatch = toolsBody.match(/data: (.+)/);
142
+ if (toolsMatch) {
143
+ const toolsData = JSON.parse(toolsMatch[1]);
144
+ toolCount = toolsData.result?.tools?.length ?? 0;
145
+ }
146
+ check(toolCount > 0, "MCP tools discovered", `${toolCount} tools`);
133
147
  }
134
- check(toolCount > 0, "MCP tools discovered", `${toolCount} tools`);
135
148
  } catch (err) {
136
149
  const msg = err instanceof Error ? err.message : "unknown error";
137
150
  check(false, "MCP server reachable", msg);
@@ -49,7 +49,7 @@ var spinner = async (label, fn) => {
49
49
  var getPackageVersion = () => {
50
50
  try {
51
51
  const __dirname = dirname(fileURLToPath(import.meta.url));
52
- const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
52
+ const pkg = JSON.parse(readFileSync(join(__dirname, "..", "..", "package.json"), "utf-8"));
53
53
  return pkg.version ?? "0.0.0";
54
54
  } catch {
55
55
  return "0.0.0";
@@ -224,8 +224,9 @@ var setupCodex = async (_apiKey) => {
224
224
  });
225
225
  const codexConfig = join(homedir(), ".codex", "config.toml");
226
226
  await spinner("Adding notify handler for Codex events", async () => {
227
- const pusharyCodexPath = execSync("which pushary-codex", { encoding: "utf-8" }).trim();
228
- if (!pusharyCodexPath) throw new Error("pushary-codex not found");
227
+ const globalPrefix = execSync("npm prefix -g", { encoding: "utf-8" }).trim();
228
+ const pusharyCodexPath = join(globalPrefix, "bin", "pushary-codex");
229
+ if (!existsSync(pusharyCodexPath)) throw new Error("pushary-codex not found at " + pusharyCodexPath);
229
230
  let config = "";
230
231
  try {
231
232
  config = readFileSync(codexConfig, "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "author": "Pushary <business@pushary.com>",
6
6
  "homepage": "https://pushary.com",