pairai 0.1.1 → 0.1.2

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/package.json +1 -1
  2. package/pairai-channel.ts +18 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pairai",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Connect AI agents to collaborate via the pairai hub — channel server for Claude Code",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/pairai-channel.ts CHANGED
@@ -67,39 +67,23 @@ if (command === "setup") {
67
67
  writeFileSync(keyPath, privateKey, { mode: 0o600 });
68
68
  console.log(` Private key: ${keyPath}\n`);
69
69
 
70
- // Configure Claude Code use "npx pairai serve" so it works anywhere
71
- try {
72
- execSync(
73
- [
74
- "claude mcp add pairai-channel",
75
- "npx -- pairai serve",
76
- `--env PAIRAI_API_KEY=${apiKey}`,
77
- `--env PAIRAI_URL=${hubUrl}`,
78
- `--env PAIRAI_PRIVATE_KEY_PATH=${keyPath}`,
79
- ].join(" "),
80
- { stdio: "inherit" }
81
- );
82
- console.log(`\n Done! Start Claude Code with:\n`);
83
- console.log(` claude --dangerously-load-development-channels server:pairai-channel\n`);
84
- } catch {
85
- console.log(` Could not run 'claude mcp add'. Add this to your .mcp.json:\n`);
86
- console.log(
87
- JSON.stringify(
88
- {
89
- mcpServers: {
90
- "pairai-channel": {
91
- command: "npx",
92
- args: ["pairai", "serve"],
93
- env: { PAIRAI_API_KEY: apiKey, PAIRAI_URL: hubUrl, PAIRAI_PRIVATE_KEY_PATH: keyPath },
94
- },
95
- },
96
- },
97
- null,
98
- 2
99
- )
100
- );
101
- console.log(`\n Then: claude --dangerously-load-development-channels server:pairai-channel\n`);
102
- }
70
+ // Write .mcp.json directly (claude mcp add --env puts env vars in args, which breaks)
71
+ const mcpConfig = {
72
+ mcpServers: {
73
+ "pairai-channel": {
74
+ command: "npx",
75
+ args: ["pairai", "serve"],
76
+ env: { PAIRAI_API_KEY: apiKey, PAIRAI_URL: hubUrl, PAIRAI_PRIVATE_KEY_PATH: keyPath },
77
+ },
78
+ },
79
+ };
80
+
81
+ const cwd = process.cwd();
82
+ const mcpJsonPath = join(cwd, ".mcp.json");
83
+ writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2) + "\n");
84
+ console.log(` MCP config: ${mcpJsonPath}\n`);
85
+ console.log(` Done! Start Claude Code with:\n`);
86
+ console.log(` claude --dangerously-load-development-channels server:pairai-channel\n`);
103
87
 
104
88
  process.exit(0);
105
89
  }
@@ -144,7 +128,7 @@ async function hubGet(path: string) {
144
128
  async function hubPost(path: string, body?: unknown) {
145
129
  const res = await fetch(`${HUB_URL}${path}`, {
146
130
  method: "POST",
147
- headers,
131
+ headers: body ? headers : { Authorization: headers.Authorization },
148
132
  body: body ? JSON.stringify(body) : undefined,
149
133
  });
150
134
  if (!res.ok) throw new Error(`POST ${path}: ${res.status}`);