@netnodeag/kraftwerk 0.78.0 → 0.78.1

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.
@@ -49,7 +49,7 @@ export function registerRemoteCommand(program) {
49
49
  remote
50
50
  .command("on")
51
51
  .description("Turn remote access on: the daemon connects to the relay")
52
- .option("--url <url>", "The cloud whose relay to use (default: the kraftwerk cloud)")
52
+ .option("--url <url>", "The cloud whose relay to use (default: this machine's cloud — env, cloud.json, else the kraftwerk cloud)")
53
53
  .action(async (opts) => {
54
54
  if (opts.url && !/^https?:\/\//.test(opts.url)) {
55
55
  console.error(chalk.red("✖ --url is the cloud's address, e.g. https://srv.kraftwerk-cloud.netnode.cloud"));
@@ -49,7 +49,13 @@ export interface RelayStatus {
49
49
  since?: string;
50
50
  }
51
51
  export declare function readRelaySettings(): Promise<RelaySettings | null>;
52
- /** Turn the relay on or off (creating the machine's key on first use); `url` switches relays. */
52
+ /**
53
+ * Turn the relay on or off (creating the machine's key on first use).
54
+ * `url` switches relays explicitly and sticks across off/on. Without it,
55
+ * turning ON re-derives the URL only while the stored one is the untouched
56
+ * default — a machine whose cloud is elsewhere (env, cloud.json) then
57
+ * relays through that cloud, while an explicit `--url` choice is kept.
58
+ */
53
59
  export declare function setRelay(enabled: boolean, url?: string): Promise<RelaySettings>;
54
60
  /**
55
61
  * The machine's key pair and secret, created (with the relay staying off)
@@ -5,6 +5,7 @@ import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { daemonHandshake, exportKeyPair, generateKeyPair, importKeyPair, relayId, toBase64, fromBase64, fromBase64Url, } from "../client/relay.js";
7
7
  import { CLOUD_DEFAULT_URL } from "../config.js";
8
+ import { machineCloud } from "../core/cloud.js";
8
9
  import { dropPushToken } from "../core/devices.js";
9
10
  import { checkMemberSession, closeMemberSession, MEMBER_HEADER, openMemberSession } from "./members.js";
10
11
  const settingsFile = () => path.join(os.homedir(), ".kraftwerk", "relay.json");
@@ -26,14 +27,22 @@ async function writeRelaySettings(s) {
26
27
  await fs.writeFile(tmp, JSON.stringify(s, null, 2), { mode: 0o600 });
27
28
  await fs.rename(tmp, file);
28
29
  }
29
- /** Turn the relay on or off (creating the machine's key on first use); `url` switches relays. */
30
+ /**
31
+ * Turn the relay on or off (creating the machine's key on first use).
32
+ * `url` switches relays explicitly and sticks across off/on. Without it,
33
+ * turning ON re-derives the URL only while the stored one is the untouched
34
+ * default — a machine whose cloud is elsewhere (env, cloud.json) then
35
+ * relays through that cloud, while an explicit `--url` choice is kept.
36
+ */
30
37
  export async function setRelay(enabled, url) {
31
38
  let s = await readRelaySettings();
39
+ const follow = !url && enabled && (!s || s.url === CLOUD_DEFAULT_URL);
40
+ const effective = url ?? (follow ? (await machineCloud()).url : undefined);
32
41
  if (!s) {
33
42
  const pair = await exportKeyPair(await generateKeyPair());
34
- s = { enabled, url: url || CLOUD_DEFAULT_URL, ...pair, secret: randomBytes(32).toString("base64url") };
43
+ s = { enabled, url: effective || CLOUD_DEFAULT_URL, ...pair, secret: randomBytes(32).toString("base64url") };
35
44
  }
36
- s = { ...s, enabled, ...(url ? { url: url.replace(/\/+$/, "") } : {}) };
45
+ s = { ...s, enabled, ...(effective ? { url: effective.replace(/\/+$/, "") } : {}) };
37
46
  await writeRelaySettings(s);
38
47
  return s;
39
48
  }
@@ -56,7 +65,7 @@ export async function ensureRelayKeys() {
56
65
  throw err;
57
66
  }
58
67
  const pair = await exportKeyPair(await generateKeyPair());
59
- const fresh = { enabled: false, url: CLOUD_DEFAULT_URL, ...pair, secret: randomBytes(32).toString("base64url") };
68
+ const fresh = { enabled: false, url: (await machineCloud()).url, ...pair, secret: randomBytes(32).toString("base64url") };
60
69
  await writeRelaySettings(fresh);
61
70
  return fresh;
62
71
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netnodeag/kraftwerk",
3
- "version": "0.78.0",
4
- "description": "Open-source agentic workspace for teams — where people and AI agents get work done together: agents (Claude Code, Codex, Pi), skills, shared knowledge, repeatable workflows, and deterministic verification",
3
+ "version": "0.78.1",
4
+ "description": "Open-source agentic workspace for teams \u2014 where people and AI agents get work done together: agents (Claude Code, Codex, Pi), skills, shared knowledge, repeatable workflows, and deterministic verification",
5
5
  "keywords": [
6
6
  "agents",
7
7
  "workflow",