@hasna/hooks 0.2.10 → 0.2.12

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.
Files changed (2) hide show
  1. package/bin/index.js +40 -1
  2. package/package.json +4 -3
package/bin/index.js CHANGED
@@ -13976,6 +13976,44 @@ function createHooksServer() {
13976
13976
  return { content: [{ type: "text", text: String(e) }], isError: true };
13977
13977
  }
13978
13978
  });
13979
+ server.tool("register_agent", "Register an agent session. Returns agent_id. Auto-triggers a heartbeat.", {
13980
+ name: z.string(),
13981
+ session_id: z.string().optional()
13982
+ }, async (params) => {
13983
+ const existing = [..._hooksAgents.values()].find((a) => a.name === params.name);
13984
+ if (existing) {
13985
+ existing.last_seen_at = new Date().toISOString();
13986
+ if (params.session_id)
13987
+ existing.session_id = params.session_id;
13988
+ return { content: [{ type: "text", text: JSON.stringify(existing) }] };
13989
+ }
13990
+ const id = Math.random().toString(36).slice(2, 10);
13991
+ const ag = { id, name: params.name, session_id: params.session_id, last_seen_at: new Date().toISOString() };
13992
+ _hooksAgents.set(id, ag);
13993
+ return { content: [{ type: "text", text: JSON.stringify(ag) }] };
13994
+ });
13995
+ server.tool("heartbeat", "Update last_seen_at to signal agent is active.", {
13996
+ agent_id: z.string()
13997
+ }, async (params) => {
13998
+ const ag = _hooksAgents.get(params.agent_id);
13999
+ if (!ag)
14000
+ return { content: [{ type: "text", text: `Agent not found: ${params.agent_id}` }], isError: true };
14001
+ ag.last_seen_at = new Date().toISOString();
14002
+ return { content: [{ type: "text", text: JSON.stringify({ agent_id: ag.id, last_seen_at: ag.last_seen_at }) }] };
14003
+ });
14004
+ server.tool("set_focus", "Set active project context for this agent session.", {
14005
+ agent_id: z.string(),
14006
+ project_id: z.string().optional()
14007
+ }, async (params) => {
14008
+ const ag = _hooksAgents.get(params.agent_id);
14009
+ if (!ag)
14010
+ return { content: [{ type: "text", text: `Agent not found: ${params.agent_id}` }], isError: true };
14011
+ ag.project_id = params.project_id;
14012
+ return { content: [{ type: "text", text: JSON.stringify({ agent_id: ag.id, project_id: ag.project_id ?? null }) }] };
14013
+ });
14014
+ server.tool("list_agents", "List all registered agents.", {}, async () => {
14015
+ return { content: [{ type: "text", text: JSON.stringify([..._hooksAgents.values()]) }] };
14016
+ });
13979
14017
  return server;
13980
14018
  }
13981
14019
  async function startSSEServer(port = MCP_PORT) {
@@ -14021,7 +14059,7 @@ async function startStdioServer() {
14021
14059
  process.exit(1);
14022
14060
  }
14023
14061
  }
14024
- var __dirname3, pkg, MCP_PORT = 39427;
14062
+ var __dirname3, pkg, MCP_PORT = 39427, _hooksAgents;
14025
14063
  var init_server = __esm(() => {
14026
14064
  init_registry();
14027
14065
  init_installer();
@@ -14037,6 +14075,7 @@ var init_server = __esm(() => {
14037
14075
  }
14038
14076
  }
14039
14077
  } catch {}
14078
+ _hooksAgents = new Map;
14040
14079
  });
14041
14080
 
14042
14081
  // src/cli/index.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/hooks",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Open source hooks library for AI coding agents - Install safety, quality, and automation hooks with a single command",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,8 @@
22
22
  "prepublishOnly": "bun run build",
23
23
  "dashboard:dev": "cd dashboard && bun run dev",
24
24
  "dashboard:build": "cd dashboard && bun run build",
25
- "dashboard:preview": "cd dashboard && bun run preview"
25
+ "dashboard:preview": "cd dashboard && bun run preview",
26
+ "postinstall": "mkdir -p $HOME/.hasna/hooks/profiles 2>/dev/null || true"
26
27
  },
27
28
  "keywords": [
28
29
  "claude-code",
@@ -75,4 +76,4 @@
75
76
  "type": "git",
76
77
  "url": "git+https://github.com/hasna/hooks.git"
77
78
  }
78
- }
79
+ }