@lightupai/polaris 0.0.95 → 0.0.97
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/package.json +1 -1
- package/skills/polaris/SKILL.md +4 -0
- package/src/cli/cli.ts +84 -29
- package/src/client/client.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightupai/polaris",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.97",
|
|
4
4
|
"description": "Record and stream Claude Code sessions to Slack. Like Gong for AI coding — capture every prompt, response, and tool call. Multiplayer collaboration across AI coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
package/skills/polaris/SKILL.md
CHANGED
|
@@ -45,4 +45,8 @@ Based on the arguments provided, do ONE of the following:
|
|
|
45
45
|
1. Call `polaris_status`
|
|
46
46
|
2. Display the current connection state
|
|
47
47
|
|
|
48
|
+
### Daemon
|
|
49
|
+
|
|
50
|
+
The Polaris daemon runs locally and is managed automatically — do NOT suggest systemd, launchd configuration, or other process managers. If the user reports the daemon is down or not starting at login, tell them to run `polaris install` which sets up auto-restart (launchd on macOS).
|
|
51
|
+
|
|
48
52
|
### Arguments: $ARGUMENTS
|
package/src/cli/cli.ts
CHANGED
|
@@ -107,6 +107,79 @@ function appToApi(appUrl: string): string {
|
|
|
107
107
|
return appUrl.replace("app.", "api.");
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
// --- LaunchAgent (macOS daemon auto-restart) ---
|
|
111
|
+
|
|
112
|
+
const LAUNCH_AGENT_LABEL = "ai.withpolaris.daemon";
|
|
113
|
+
const LAUNCH_AGENT_PLIST = join(homedir(), "Library", "LaunchAgents", `${LAUNCH_AGENT_LABEL}.plist`);
|
|
114
|
+
|
|
115
|
+
// Writes a runner script + launchd plist so the daemon survives crashes and
|
|
116
|
+
// starts automatically at login. No-op on non-macOS platforms.
|
|
117
|
+
async function installLaunchAgent(daemonSecret?: string): Promise<void> {
|
|
118
|
+
if (process.platform !== "darwin") return;
|
|
119
|
+
|
|
120
|
+
const binDir = join(POLARIS_DIR, "bin");
|
|
121
|
+
const runnerPath = join(binDir, "run-daemon.sh");
|
|
122
|
+
const daemonTsPath = join(
|
|
123
|
+
POLARIS_DIR, "mcp", "node_modules", "@lightupai", "polaris", "src", "daemon", "daemon.ts"
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
await mkdir(binDir, { recursive: true });
|
|
127
|
+
// Runner searches common bun locations so launchd's minimal PATH is not an issue
|
|
128
|
+
const runner = [
|
|
129
|
+
"#!/bin/sh",
|
|
130
|
+
`# Polaris daemon — managed by launchd (${LAUNCH_AGENT_LABEL})`,
|
|
131
|
+
`for BUNPATH in "$HOME/.bun/bin/bun" /opt/homebrew/bin/bun /usr/local/bin/bun; do`,
|
|
132
|
+
` [ -x "$BUNPATH" ] && break`,
|
|
133
|
+
`done`,
|
|
134
|
+
`exec "$BUNPATH" run "${daemonTsPath}"`,
|
|
135
|
+
].join("\n") + "\n";
|
|
136
|
+
await writeFile(runnerPath, runner);
|
|
137
|
+
await chmod(runnerPath, 0o755);
|
|
138
|
+
|
|
139
|
+
const secretEnv = daemonSecret
|
|
140
|
+
? `\n <key>EnvironmentVariables</key>\n <dict>\n <key>POLARIS_DAEMON_SECRET</key>\n <string>${daemonSecret}</string>\n </dict>`
|
|
141
|
+
: "";
|
|
142
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
143
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
144
|
+
<plist version="1.0">
|
|
145
|
+
<dict>
|
|
146
|
+
<key>Label</key>
|
|
147
|
+
<string>${LAUNCH_AGENT_LABEL}</string>
|
|
148
|
+
<key>ProgramArguments</key>
|
|
149
|
+
<array>
|
|
150
|
+
<string>${runnerPath}</string>
|
|
151
|
+
</array>${secretEnv}
|
|
152
|
+
<key>KeepAlive</key>
|
|
153
|
+
<true/>
|
|
154
|
+
<key>RunAtLoad</key>
|
|
155
|
+
<true/>
|
|
156
|
+
<key>ThrottleInterval</key>
|
|
157
|
+
<integer>5</integer>
|
|
158
|
+
<key>StandardOutPath</key>
|
|
159
|
+
<string>/tmp/polaris-daemon.log</string>
|
|
160
|
+
<key>StandardErrorPath</key>
|
|
161
|
+
<string>/tmp/polaris-daemon.log</string>
|
|
162
|
+
</dict>
|
|
163
|
+
</plist>`;
|
|
164
|
+
|
|
165
|
+
await mkdir(join(homedir(), "Library", "LaunchAgents"), { recursive: true });
|
|
166
|
+
await writeFile(LAUNCH_AGENT_PLIST, plist);
|
|
167
|
+
|
|
168
|
+
// Unload any existing instance, then load fresh (ignore errors if not loaded yet)
|
|
169
|
+
Bun.spawnSync(["launchctl", "unload", "-w", LAUNCH_AGENT_PLIST], { stdout: "ignore", stderr: "ignore" });
|
|
170
|
+
const load = Bun.spawnSync(["launchctl", "load", "-w", LAUNCH_AGENT_PLIST], { stdout: "pipe", stderr: "pipe" });
|
|
171
|
+
if (load.exitCode !== 0) {
|
|
172
|
+
console.error(` Warning: could not register daemon with launchd: ${load.stderr.toString().trim()}`);
|
|
173
|
+
console.error(` Try manually: launchctl load -w ${LAUNCH_AGENT_PLIST}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function removeLaunchAgent(): Promise<void> {
|
|
178
|
+
if (process.platform !== "darwin") return;
|
|
179
|
+
Bun.spawnSync(["launchctl", "unload", "-w", LAUNCH_AGENT_PLIST], { stdout: "ignore", stderr: "ignore" });
|
|
180
|
+
try { await rm(LAUNCH_AGENT_PLIST); } catch { /* already gone */ }
|
|
181
|
+
}
|
|
182
|
+
|
|
110
183
|
// --- Daemon secret ---
|
|
111
184
|
|
|
112
185
|
// Shared local secret for daemon HTTP auth. Stored in ~/.polaris/config.json
|
|
@@ -272,6 +345,10 @@ Based on the arguments provided, do ONE of the following:
|
|
|
272
345
|
1. Call \`polaris_status\`
|
|
273
346
|
2. Display the current connection state
|
|
274
347
|
|
|
348
|
+
### Daemon
|
|
349
|
+
|
|
350
|
+
The Polaris daemon runs locally and is managed automatically — do NOT suggest systemd, launchd configuration, or other process managers. If the user reports the daemon is down or not starting at login, tell them to run \`polaris install\` which sets up auto-restart (launchd on macOS).
|
|
351
|
+
|
|
275
352
|
### Arguments: $ARGUMENTS
|
|
276
353
|
`;
|
|
277
354
|
await writeFile(join(skillDir, "SKILL.md"), skillContent);
|
|
@@ -782,6 +859,7 @@ async function recover() {
|
|
|
782
859
|
|
|
783
860
|
async function logout(all = false) {
|
|
784
861
|
if (all) {
|
|
862
|
+
await removeLaunchAgent();
|
|
785
863
|
try {
|
|
786
864
|
await rm(POLARIS_DIR, { recursive: true });
|
|
787
865
|
console.log("All profiles and credentials removed.");
|
|
@@ -884,17 +962,8 @@ switch (command) {
|
|
|
884
962
|
case "install":
|
|
885
963
|
console.log("Polaris — installing local components\n");
|
|
886
964
|
await install();
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
{
|
|
890
|
-
const daemonPath = join(import.meta.dir, "..", "daemon", "daemon.ts");
|
|
891
|
-
Bun.spawn(["bun", "run", daemonPath], {
|
|
892
|
-
stdout: "ignore",
|
|
893
|
-
stderr: "ignore",
|
|
894
|
-
env: { ...process.env },
|
|
895
|
-
}).unref?.();
|
|
896
|
-
}
|
|
897
|
-
console.log(" ✓ Daemon restarted");
|
|
965
|
+
await installLaunchAgent(await ensureDaemonSecret());
|
|
966
|
+
console.log(" ✓ Daemon registered with launchd (auto-restarts on crash, starts at login)");
|
|
898
967
|
console.log("\nInstall complete.");
|
|
899
968
|
break;
|
|
900
969
|
|
|
@@ -904,15 +973,8 @@ switch (command) {
|
|
|
904
973
|
console.log("Polaris — authenticating\n");
|
|
905
974
|
await login(appUrl, profileName);
|
|
906
975
|
console.log("\n✓ Login complete!");
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const daemonPath = join(import.meta.dir, "..", "daemon", "daemon.ts");
|
|
910
|
-
Bun.spawn(["bun", "run", daemonPath], {
|
|
911
|
-
stdout: "ignore",
|
|
912
|
-
stderr: "ignore",
|
|
913
|
-
env: { ...process.env },
|
|
914
|
-
}).unref?.();
|
|
915
|
-
console.log(" ✓ Daemon started in background");
|
|
976
|
+
await installLaunchAgent(await ensureDaemonSecret());
|
|
977
|
+
console.log(" ✓ Daemon restarted");
|
|
916
978
|
|
|
917
979
|
console.log("\nNext: restart Claude Code, then run `/polaris join #channel-name` in your AI agent.");
|
|
918
980
|
break;
|
|
@@ -965,15 +1027,8 @@ switch (command) {
|
|
|
965
1027
|
console.log("[2/2] Authenticating...\n");
|
|
966
1028
|
await login(DEFAULT_APP_URL);
|
|
967
1029
|
console.log("\n✓ Polaris is set up on this machine!");
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
const daemonPath = join(import.meta.dir, "..", "daemon", "daemon.ts");
|
|
971
|
-
Bun.spawn(["bun", "run", daemonPath], {
|
|
972
|
-
stdout: "ignore",
|
|
973
|
-
stderr: "ignore",
|
|
974
|
-
env: { ...process.env },
|
|
975
|
-
}).unref?.();
|
|
976
|
-
console.log(" ✓ Daemon started in background");
|
|
1030
|
+
await installLaunchAgent(await ensureDaemonSecret());
|
|
1031
|
+
console.log(" ✓ Daemon registered with launchd (auto-restarts on crash, starts at login)");
|
|
977
1032
|
|
|
978
1033
|
console.log("\nNext: restart Claude Code, then run `/polaris join #channel-name` in your AI agent.");
|
|
979
1034
|
break;
|
package/src/client/client.ts
CHANGED
|
@@ -100,7 +100,9 @@ const mcp = new Server(
|
|
|
100
100
|
experimental: { "claude/channel": {} },
|
|
101
101
|
tools: {},
|
|
102
102
|
},
|
|
103
|
-
instructions: `You are connected to Polaris — a multiplayer collaboration system. Messages from advisors and teammates may arrive as <channel source="polaris" from="..."> tags. Use /polaris commands to manage your session, or call the polaris tools directly
|
|
103
|
+
instructions: `You are connected to Polaris — a multiplayer collaboration system. Messages from advisors and teammates may arrive as <channel source="polaris" from="..."> tags. Use /polaris commands to manage your session, or call the polaris tools directly.
|
|
104
|
+
|
|
105
|
+
If the user reports the Polaris daemon is not running or keeps crashing, tell them to run \`polaris install\` — it registers the daemon with launchd (macOS) for auto-restart on crash and at login. Do NOT suggest systemd, manual launchd configuration, or other process managers.`,
|
|
104
106
|
}
|
|
105
107
|
);
|
|
106
108
|
|