hinacode 0.1.0-alpha.16 → 0.2.0-alpha.0

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.
@@ -4,7 +4,7 @@ import { homedir, hostname } from "node:os";
4
4
  import { dirname, delimiter, basename, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import QRCode from "qrcode";
7
- import { S as Struct, e as effect, U as Updates, g as gen, u as unsupported, E as Events, t as tryPromise, d as decodeUnknownSync, m as make$1, s as suspend, r as repeat, a as spaced, f as forkScoped, T as Threads, W as Worktrees, b as Terminals, c as forEach, o as orElseSucceed, h as sync, i as isThreadBusy, j as String$1, v as void_, k as andThen, l as matchEffect, n as forkDetach, p as flatMap, q as UsageError, w as USAGE, x as parseCommand, y as serveConfig, z as hydratePath, A as make$2, B as makeAppLayer, C as autoUpdate, D as layer$1, F as provideMerge, G as mergeAll, H as layer$2, I as layer$3, J as provide, K as noKeyring, L as layer$4, M as succeed, N as MinimumLogLevel, O as Settings, R as RemoteAccess, P as pairingUrl, Q as isPortInUse, V as restartCommand } from "./chunks/shellPath-C5Y1eV3_.js";
7
+ import { S as Struct, e as effect, U as Updates, g as gen, u as unsupported, E as Events, t as tryPromise, d as decodeUnknownSync, m as make$1, s as suspend, r as repeat, a as spaced, f as forkScoped, T as Threads, W as Worktrees, b as Terminals, c as forEach, o as orElseSucceed, h as sync, i as isThreadBusy, j as String$1, v as void_, k as andThen, l as matchEffect, n as forkDetach, p as flatMap, q as UsageError, w as USAGE, x as parseCommand, y as serveConfig, z as hydratePath, A as make$2, B as makeAppLayer, C as autoUpdate, D as applyServeRelay, R as RemoteAccess, F as layer$1, G as provideMerge, H as mergeAll, I as layer$2, J as layer$3, K as noKeyring, L as layer$4, M as provide, N as succeed, O as MinimumLogLevel, P as Settings, Q as storedTunnel, V as isPortInUse, X as pairingUrl, Y as restartCommand } from "./chunks/shellPath-B8h-TJ4C.js";
8
8
  import { execFile } from "node:child_process";
9
9
  import { promisify } from "node:util";
10
10
  import "node:crypto";
@@ -23,6 +23,9 @@ import "node:zlib";
23
23
  import "ws";
24
24
  import "node:net";
25
25
  import "node:tls";
26
+ import "@noble/hashes/hmac.js";
27
+ import "@noble/hashes/sha2.js";
28
+ import "@noble/hashes/utils.js";
26
29
  const execFileAsync = promisify(execFile);
27
30
  const CHECK_INTERVAL = "4 hours";
28
31
  const AUTO_INSTALL_INTERVAL = "1 minute";
@@ -161,12 +164,17 @@ const pairingText = async (userData, pairing) => {
161
164
  "Pair a phone: scan this code in the HinaCode app, or paste the URL.",
162
165
  ` ${phoneUrl}`,
163
166
  qr,
167
+ ...pairing.relay === null ? [] : [`Reachable from any network through ${pairing.relay}.`, ""],
164
168
  "Pair a desktop: Settings > Environments > Add environment, with one of:",
165
169
  ...pairing.hosts.map((host) => ` ${pairingUrl({ ...pairing, hosts: [host] })}`),
166
170
  "Keep the token in these URLs private. Run `hinacode pair` to print them again.",
167
171
  ""
168
172
  ].join("\n");
169
173
  };
174
+ const printLink = ({ url, userCode }) => sync(
175
+ () => process.stdout.write(`Open ${url} to link this cloud to your HinaCode account. The code is ${userCode}.
176
+ `)
177
+ );
170
178
  const listening = async (runtime) => {
171
179
  const deadline = Date.now() + LISTEN_TIMEOUT_MS;
172
180
  for (; ; ) {
@@ -182,7 +190,6 @@ const listening = async (runtime) => {
182
190
  if (Date.now() > deadline) throw new Error("remote listener did not start in time");
183
191
  await new Promise((resolve) => setTimeout(resolve, 50));
184
192
  }
185
- return runtime.runPromise(RemoteAccess.use((remote) => remote.pairing));
186
193
  };
187
194
  const serve = async (argv, userData) => {
188
195
  const config = serveConfig(argv, process.env);
@@ -221,7 +228,15 @@ const serve = async (argv, userData) => {
221
228
  process.on("SIGINT", quit);
222
229
  process.on("SIGTERM", quit);
223
230
  await runtime.runPromise(void_);
224
- process.stdout.write(await pairingText(userData, await listening(runtime)));
231
+ await listening(runtime);
232
+ try {
233
+ await runtime.runPromise(applyServeRelay(config.relay, printLink));
234
+ } catch (error) {
235
+ await runtime.dispose();
236
+ throw error;
237
+ }
238
+ const pairing = await runtime.runPromise(RemoteAccess.use((remote) => remote.pairing));
239
+ process.stdout.write(await pairingText(userData, pairing));
225
240
  };
226
241
  const pair = async (userData) => {
227
242
  const database = join(userData, "hinacode.sqlite");
@@ -234,7 +249,7 @@ const pair = async (userData) => {
234
249
  const runtime = make$2(
235
250
  layer$1.pipe(
236
251
  provideMerge(mergeAll(layer$3, layer$2)),
237
- provide(mergeAll(layer$4(database), noKeyring)),
252
+ provideMerge(mergeAll(layer$4(database), noKeyring)),
238
253
  provide(succeed(MinimumLogLevel, "Warn"))
239
254
  )
240
255
  );
@@ -242,7 +257,8 @@ const pair = async (userData) => {
242
257
  const { remote } = await runtime.runPromise(Settings.use((settings) => settings.get));
243
258
  if (!remote.enabled) return noCloud();
244
259
  const pairing = await runtime.runPromise(RemoteAccess.use((access) => access.pairing));
245
- process.stdout.write(await pairingText(userData, pairing));
260
+ const tunnel = await runtime.runPromise(storedTunnel);
261
+ process.stdout.write(await pairingText(userData, { ...pairing, relay: tunnel?.hostname ?? null }));
246
262
  } finally {
247
263
  await runtime.dispose();
248
264
  }
package/out/main/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { existsSync, renameSync } from "node:fs";
2
2
  import { join, delimiter } from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
- import { Notification, nativeImage, BrowserWindow, ipcMain, app, dialog, shell, protocol, safeStorage, powerMonitor, Menu, net, session } from "electron";
5
- import { h as sync, X as catchDefect, Y as succeed, Z as callback, _ as timeoutOrElse, $ as seconds, a0 as TaggedError, j as String$1, a1 as promise, t as tryPromise, S as Struct, a2 as optional, a3 as RpcCall, a4 as decodeUnknownOption, a5 as EVENT_CHANNEL, a6 as RPC_CHANNEL, a7 as isTrustedSender, g as gen, a8 as getOrUndefined, a9 as dispatch, aa as Environments, p as flatMap, ab as catch_, ac as all$1, ad as map, ae as decodeUnknownEffect, af as RpcMethods, ag as inlineSource, u as unsupported, E as Events, ah as runFork, ai as logWarning, r as repeat, a as spaced, f as forkScoped, U as Updates, s as suspend, e as effect, v as void_, aj as ignore, z as hydratePath, ak as ATTACHMENT_PROTOCOL, al as GITHUB_ASSET_PROTOCOL, am as PROJECT_FILE_PROTOCOL, M as succeed$1, an as Keyring, A as make$1, B as makeAppLayer, ao as isInside, ap as githubAssetId, aq as GitHub, ar as externalUrl, as as projectFileRequest, at as Files, au as BROWSER_PARTITION, av as lockDownWebview, aw as isAllowedNavigation } from "./chunks/shellPath-C5Y1eV3_.js";
4
+ import { Notification, nativeImage, BrowserWindow, ipcMain, app, shell, dialog, protocol, safeStorage, powerMonitor, Menu, net, session } from "electron";
5
+ import { h as sync, Z as catchDefect, _ as succeed, $ as callback, a0 as timeoutOrElse, a1 as seconds, a2 as TaggedError, j as String$1, a3 as promise, t as tryPromise, S as Struct, a4 as optional, a5 as RpcCall, a6 as decodeUnknownOption, a7 as EVENT_CHANNEL, a8 as RPC_CHANNEL, a9 as isTrustedSender, g as gen, aa as getOrUndefined, ab as dispatch, ac as Environments, p as flatMap, ad as catch_, ae as all$1, af as map, ag as externalUrl, v as void_, ah as logWarning, ai as decodeUnknownEffect, aj as RpcMethods, ak as inlineSource, u as unsupported, E as Events, al as runFork, r as repeat, a as spaced, f as forkScoped, U as Updates, s as suspend, e as effect, am as ignore, z as hydratePath, an as ATTACHMENT_PROTOCOL, ao as GITHUB_ASSET_PROTOCOL, ap as PROJECT_FILE_PROTOCOL, N as succeed$1, aq as Keyring, A as make$1, B as makeAppLayer, ar as isInside, as as githubAssetId, at as GitHub, au as projectFileRequest, av as Files, aw as BROWSER_PARTITION, ax as lockDownWebview, ay as isAllowedNavigation } from "./chunks/shellPath-B8h-TJ4C.js";
6
6
  import { createRequire } from "node:module";
7
7
  import { execFile, spawn } from "node:child_process";
8
8
  import { access } from "node:fs/promises";
@@ -25,6 +25,9 @@ import "node:zlib";
25
25
  import "ws";
26
26
  import "node:net";
27
27
  import "node:tls";
28
+ import "@noble/hashes/hmac.js";
29
+ import "@noble/hashes/sha2.js";
30
+ import "@noble/hashes/utils.js";
28
31
  const client = { to: "client" };
29
32
  const all = { to: "all" };
30
33
  const named = { to: "named" };
@@ -48,6 +51,15 @@ const routes = {
48
51
  "environments.add": client,
49
52
  "environments.remove": client,
50
53
  "environments.reconnect": client,
54
+ "relayAccount.status": client,
55
+ "relayAccount.signIn": client,
56
+ "relayAccount.signOut": client,
57
+ "relayAccount.sync": client,
58
+ "relayAccount.machines": client,
59
+ "relayAccount.setShown": client,
60
+ "relayAccount.removeMachine": client,
61
+ "relayAccount.pendingLink": client,
62
+ "relayAccount.approveLink": client,
51
63
  "updates.status": named,
52
64
  "updates.check": named,
53
65
  "updates.install": named,
@@ -82,9 +94,13 @@ const routes = {
82
94
  "github.merge": named,
83
95
  "github.close": named,
84
96
  "vm.host": named,
97
+ "network.addresses": named,
98
+ "system.resources": named,
85
99
  "remote.status": named,
86
100
  "remote.pairing": named,
87
101
  "remote.rotateToken": named,
102
+ "remote.setupRelay": named,
103
+ "remote.removeRelay": named,
88
104
  "projects.create": named,
89
105
  "projects.clone": named,
90
106
  "ports.kill": named,
@@ -280,6 +296,12 @@ const desktopCalls = (window) => ({
280
296
  if (window) bringToFront(window);
281
297
  }),
282
298
  reveal: (path) => sync(() => shell.showItemInFolder(path)),
299
+ openExternal: (url) => {
300
+ const allowed = externalUrl(url);
301
+ return allowed === null ? void_ : tryPromise(() => shell.openExternal(allowed)).pipe(
302
+ catch_((error) => logWarning("could not open the browser", error))
303
+ );
304
+ },
283
305
  openers: listOpeners,
284
306
  openWith,
285
307
  pickFolder: map(
@@ -381,7 +403,8 @@ const make = gen(function* () {
381
403
  });
382
404
  });
383
405
  const layer = effect(Updates, make);
384
- const icon = join$1(import.meta.dirname, "./chunks/icon-B49l-pLu.png");
406
+ const devIcon = join$1(import.meta.dirname, "./chunks/icon-dev-DGWXI65o.png");
407
+ const releaseIcon = join$1(import.meta.dirname, "./chunks/icon-B49l-pLu.png");
385
408
  app.setName("kkcode");
386
409
  if (process.platform === "win32") app.setAppUserModelId("app.hinacode");
387
410
  const userDataOverride = process.env["HINACODE_USER_DATA"];
@@ -393,6 +416,7 @@ if (!app.requestSingleInstanceLock()) {
393
416
  app.exit(0);
394
417
  }
395
418
  if (!app.isPackaged) startResourceMonitor(app.getPath("userData"));
419
+ const icon = app.isPackaged ? releaseIcon : devIcon;
396
420
  const pathHydrated = hydratePath(process.env);
397
421
  protocol.registerSchemesAsPrivileged([
398
422
  { scheme: ATTACHMENT_PROTOCOL, privileges: { standard: true, secure: true } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hinacode",
3
- "version": "0.1.0-alpha.16",
3
+ "version": "0.2.0-alpha.0",
4
4
  "description": "Run coding agents on this machine and drive them from the HinaCode desktop or phone app",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,13 +40,16 @@
40
40
  "@anthropic-ai/claude-agent-sdk": "0.3.296",
41
41
  "@effect/platform-node": "4.0.3",
42
42
  "@effect/sql-sqlite-node": "4.0.3",
43
+ "@fontsource-variable/geist": "^5.3.0",
43
44
  "@linear/sdk": "97.1.0",
44
45
  "@modelcontextprotocol/sdk": "1.32.1",
45
46
  "@muse-code/sdk": "1.4.7",
47
+ "@noble/hashes": "2.4.0",
46
48
  "anser": "2.3.5",
47
49
  "effect": "4.0.3",
48
50
  "electron-updater": "6.8.9",
49
51
  "node-pty": "1.2.0-beta.15",
52
+ "pele": "1.9.0",
50
53
  "qrcode": "^1.5.4",
51
54
  "ws": "8.22.0"
52
55
  },
@@ -87,7 +90,6 @@
87
90
  "electron-builder": "26.17.0",
88
91
  "electron-vite": "5.0.0",
89
92
  "fuzzysort": "4.0.2",
90
- "mermaid": "12.1.0",
91
93
  "motion": "14.2.0",
92
94
  "node-gyp": "12.2.0",
93
95
  "oxfmt": "0.72.0",