@hasna/economy 0.2.3 → 0.2.4

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/mcp/index.js CHANGED
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  var __defProp = Object.defineProperty;
4
+ var __returnValue = (v) => v;
5
+ function __exportSetter(name, newValue) {
6
+ this[name] = __returnValue.bind(null, newValue);
7
+ }
4
8
  var __export = (target, all) => {
5
9
  for (var name in all)
6
10
  __defProp(target, name, {
7
11
  get: all[name],
8
12
  enumerable: true,
9
13
  configurable: true,
10
- set: (newValue) => all[name] = () => newValue
14
+ set: __exportSetter.bind(all, name)
11
15
  });
12
16
  };
13
17
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -732,5 +736,31 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
732
736
  return { content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : String(e)}` }], isError: true };
733
737
  }
734
738
  });
739
+ var _agentReg = new Map;
740
+ server.tool("register_agent", "Register this agent session. Returns agent_id for use in heartbeat/set_focus.", { name: z.string(), session_id: z.string().optional() }, async (a) => {
741
+ const existing = [..._agentReg.values()].find((x) => x.name === a.name);
742
+ if (existing) {
743
+ existing.last_seen_at = new Date().toISOString();
744
+ return { content: [{ type: "text", text: JSON.stringify(existing) }] };
745
+ }
746
+ const id = Math.random().toString(36).slice(2, 10);
747
+ const ag = { id, name: a.name, last_seen_at: new Date().toISOString() };
748
+ _agentReg.set(id, ag);
749
+ return { content: [{ type: "text", text: JSON.stringify(ag) }] };
750
+ });
751
+ server.tool("heartbeat", "Update last_seen_at to signal agent is active.", { agent_id: z.string() }, async (a) => {
752
+ const ag = _agentReg.get(a.agent_id);
753
+ if (!ag)
754
+ return { content: [{ type: "text", text: `Agent not found: ${a.agent_id}` }], isError: true };
755
+ ag.last_seen_at = new Date().toISOString();
756
+ return { content: [{ type: "text", text: `\u2665 ${ag.name} \u2014 active` }] };
757
+ });
758
+ server.tool("set_focus", "Set active project context for this agent session.", { agent_id: z.string(), project_id: z.string().optional() }, async (a) => {
759
+ const ag = _agentReg.get(a.agent_id);
760
+ if (!ag)
761
+ return { content: [{ type: "text", text: `Agent not found: ${a.agent_id}` }], isError: true };
762
+ ag.project_id = a.project_id;
763
+ return { content: [{ type: "text", text: a.project_id ? `Focus: ${a.project_id}` : "Focus cleared" }] };
764
+ });
735
765
  var transport = new StdioServerTransport;
736
766
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/economy",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "AI coding cost tracker — CLI + MCP server + REST API + web dashboard for Claude Code, Codex, and Gemini",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +0,0 @@
1
- import type { Agent } from '../../types/index.js';
2
- interface WatchOptions {
3
- interval: number;
4
- agent?: Agent;
5
- }
6
- export declare function watchCosts(opts: WatchOptions): Promise<void>;
7
- export {};
8
- //# sourceMappingURL=watch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/watch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAEjD,UAAU,YAAY;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAuBD,wBAAsB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiElE"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bun
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}