hinacode 0.1.0-alpha.17 → 0.2.0-alpha.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.
@@ -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-EFVRaOTT.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-b-g7j5HA.js";
8
8
  import { execFile } from "node:child_process";
9
9
  import { promisify } from "node:util";
10
10
  import "node:crypto";
@@ -17,10 +17,14 @@ import "@modelcontextprotocol/sdk/types.js";
17
17
  import "@muse-code/sdk";
18
18
  import "node:sqlite";
19
19
  import "node-pty";
20
+ import "playwright";
21
+ import "ws";
22
+ import "@noble/hashes/hmac.js";
23
+ import "@noble/hashes/sha2.js";
24
+ import "@noble/hashes/utils.js";
20
25
  import "node:http";
21
26
  import "node:stream/promises";
22
27
  import "node:zlib";
23
- import "ws";
24
28
  import "node:net";
25
29
  import "node:tls";
26
30
  const execFileAsync = promisify(execFile);
@@ -161,12 +165,17 @@ const pairingText = async (userData, pairing) => {
161
165
  "Pair a phone: scan this code in the HinaCode app, or paste the URL.",
162
166
  ` ${phoneUrl}`,
163
167
  qr,
168
+ ...pairing.relay === null ? [] : [`Reachable from any network through ${pairing.relay}.`, ""],
164
169
  "Pair a desktop: Settings > Environments > Add environment, with one of:",
165
170
  ...pairing.hosts.map((host) => ` ${pairingUrl({ ...pairing, hosts: [host] })}`),
166
171
  "Keep the token in these URLs private. Run `hinacode pair` to print them again.",
167
172
  ""
168
173
  ].join("\n");
169
174
  };
175
+ const printLink = ({ url, userCode }) => sync(
176
+ () => process.stdout.write(`Open ${url} to link this cloud to your HinaCode account. The code is ${userCode}.
177
+ `)
178
+ );
170
179
  const listening = async (runtime) => {
171
180
  const deadline = Date.now() + LISTEN_TIMEOUT_MS;
172
181
  for (; ; ) {
@@ -182,7 +191,6 @@ const listening = async (runtime) => {
182
191
  if (Date.now() > deadline) throw new Error("remote listener did not start in time");
183
192
  await new Promise((resolve) => setTimeout(resolve, 50));
184
193
  }
185
- return runtime.runPromise(RemoteAccess.use((remote) => remote.pairing));
186
194
  };
187
195
  const serve = async (argv, userData) => {
188
196
  const config = serveConfig(argv, process.env);
@@ -221,7 +229,15 @@ const serve = async (argv, userData) => {
221
229
  process.on("SIGINT", quit);
222
230
  process.on("SIGTERM", quit);
223
231
  await runtime.runPromise(void_);
224
- process.stdout.write(await pairingText(userData, await listening(runtime)));
232
+ await listening(runtime);
233
+ try {
234
+ await runtime.runPromise(applyServeRelay(config.relay, printLink));
235
+ } catch (error) {
236
+ await runtime.dispose();
237
+ throw error;
238
+ }
239
+ const pairing = await runtime.runPromise(RemoteAccess.use((remote) => remote.pairing));
240
+ process.stdout.write(await pairingText(userData, pairing));
225
241
  };
226
242
  const pair = async (userData) => {
227
243
  const database = join(userData, "hinacode.sqlite");
@@ -234,7 +250,7 @@ const pair = async (userData) => {
234
250
  const runtime = make$2(
235
251
  layer$1.pipe(
236
252
  provideMerge(mergeAll(layer$3, layer$2)),
237
- provide(mergeAll(layer$4(database), noKeyring)),
253
+ provideMerge(mergeAll(layer$4(database), noKeyring)),
238
254
  provide(succeed(MinimumLogLevel, "Warn"))
239
255
  )
240
256
  );
@@ -242,7 +258,8 @@ const pair = async (userData) => {
242
258
  const { remote } = await runtime.runPromise(Settings.use((settings) => settings.get));
243
259
  if (!remote.enabled) return noCloud();
244
260
  const pairing = await runtime.runPromise(RemoteAccess.use((access) => access.pairing));
245
- process.stdout.write(await pairingText(userData, pairing));
261
+ const tunnel = await runtime.runPromise(storedTunnel);
262
+ process.stdout.write(await pairingText(userData, { ...pairing, relay: tunnel?.hostname ?? null }));
246
263
  } finally {
247
264
  await runtime.dispose();
248
265
  }
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-EFVRaOTT.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, a4 as EVENT_CHANNEL, a5 as RPC_CHANNEL, a6 as isTrustedSender, a7 as route, a8 as map, a9 as externalUrl, v as void_, aa as catch_, ab as logWarning, g as gen, u as unsupported, E as Events, ac as runFork, r as repeat, a as spaced, f as forkScoped, U as Updates, s as suspend, e as effect, ad as ignore, z as hydratePath, ae as ATTACHMENT_PROTOCOL, af as GITHUB_ASSET_PROTOCOL, ag as PROJECT_FILE_PROTOCOL, ah as decodeUnknownOption, ai as RpcMethods, N as succeed$1, aj as Keyring, A as make$1, B as makeAppLayer, p as flatMap, ak as Environments, al as isInside, am as githubAssetId, an as GitHub, ao as projectFileRequest, ap as Files, aq as BROWSER_PARTITION, ar as lockDownWebview, as as getOrUndefined, at as isAllowedNavigation } from "./chunks/shellPath-b-g7j5HA.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";
@@ -19,159 +19,16 @@ import "@modelcontextprotocol/sdk/types.js";
19
19
  import "@muse-code/sdk";
20
20
  import "node:sqlite";
21
21
  import "node-pty";
22
+ import "playwright";
23
+ import "ws";
24
+ import "@noble/hashes/hmac.js";
25
+ import "@noble/hashes/sha2.js";
26
+ import "@noble/hashes/utils.js";
22
27
  import "node:http";
23
28
  import "node:stream/promises";
24
29
  import "node:zlib";
25
- import "ws";
26
30
  import "node:net";
27
31
  import "node:tls";
28
- const client = { to: "client" };
29
- const all = { to: "all" };
30
- const named = { to: "named" };
31
- const owner = (entity, key) => ({ to: "owner", entity, key });
32
- const thread = owner("thread", "threadId");
33
- const project = owner("project", "id");
34
- const root = owner("root", "root");
35
- const routes = {
36
- "app.ready": client,
37
- "app.focus": client,
38
- "dialog.pickFolder": client,
39
- "dialog.pickFiles": client,
40
- "shell.reveal": client,
41
- "shell.openers": client,
42
- "shell.openWith": client,
43
- "notifications.permission": client,
44
- "notifications.askPermission": client,
45
- "clientSettings.get": client,
46
- "clientSettings.set": client,
47
- "environments.list": client,
48
- "environments.add": client,
49
- "environments.remove": client,
50
- "environments.reconnect": client,
51
- "updates.status": named,
52
- "updates.check": named,
53
- "updates.install": named,
54
- "agents.updates": client,
55
- "agents.update": client,
56
- "links.favicon": client,
57
- "projects.list": all,
58
- "threads.list": all,
59
- "worktrees.list": all,
60
- "worktrees.checkouts": all,
61
- "pullRequests.all": all,
62
- "linear.issues": all,
63
- "limits.list": named,
64
- "search.threads": all,
65
- "settings.get": named,
66
- "settings.set": named,
67
- "accounts.list": named,
68
- "accounts.create": named,
69
- "accounts.rename": named,
70
- "accounts.delete": named,
71
- "agents.account": named,
72
- "models.list": named,
73
- "secrets.has": named,
74
- "secrets.set": named,
75
- "secrets.clear": named,
76
- "github.auth": named,
77
- "github.pullRequest": named,
78
- "github.pullRequestDetail": named,
79
- "github.pullRequestFiles": named,
80
- "pullRequestGuides.get": named,
81
- "pullRequestGuides.retry": named,
82
- "github.merge": named,
83
- "github.close": named,
84
- "vm.host": named,
85
- "network.addresses": named,
86
- "remote.status": named,
87
- "remote.pairing": named,
88
- "remote.rotateToken": named,
89
- "projects.create": named,
90
- "projects.clone": named,
91
- "ports.kill": named,
92
- "automations.list": named,
93
- "projects.update": project,
94
- "projects.delete": project,
95
- "projects.currentBranch": project,
96
- "projects.defaultBranch": project,
97
- "projects.branches": project,
98
- "projects.pullRequests": project,
99
- "projects.searchPullRequests": project,
100
- "projects.fetch": project,
101
- "projects.icon": project,
102
- "threads.create": owner("project", "projectId"),
103
- "worktrees.create": owner("project", "projectId"),
104
- "automations.create": owner("project", "projectId"),
105
- "github.repository": owner("project", "projectId"),
106
- "threads.update": owner("thread", "id"),
107
- "threads.delete": owner("thread", "id"),
108
- "threads.resumeAtReset": owner("thread", "id"),
109
- "threads.switchAccount": owner("thread", "id"),
110
- "threads.changes": thread,
111
- "threads.archive": thread,
112
- "threads.unarchive": thread,
113
- "threads.transcript": thread,
114
- "threads.send": thread,
115
- "threads.steer": thread,
116
- "threads.queue": thread,
117
- "threads.unqueue": thread,
118
- "threads.interrupt": thread,
119
- "threads.usage": thread,
120
- "commands.list": thread,
121
- "files.list": thread,
122
- "search.files": thread,
123
- "subagents.list": thread,
124
- "subagents.stop": thread,
125
- "backgroundTasks.list": thread,
126
- "backgroundTasks.stop": thread,
127
- "pullRequests.list": thread,
128
- "pullRequests.unlink": thread,
129
- "pullRequests.create": thread,
130
- "pullRequests.watch": thread,
131
- "pullRequests.unwatch": thread,
132
- "mcp.connection": thread,
133
- "ports.list": thread,
134
- "terminal.open": thread,
135
- "terminal.list": thread,
136
- "vm.get": thread,
137
- "vm.start": thread,
138
- "vm.stop": thread,
139
- "vm.control": thread,
140
- "vm.screen.open": thread,
141
- "vm.files.drop": thread,
142
- "vm.profile.save": thread,
143
- "vm.screenshot.save": thread,
144
- "vm.passkey.get": thread,
145
- "vm.passkey.prepare": thread,
146
- "vm.passkey.cancel": thread,
147
- "attachments.stage": thread,
148
- "attachments.read": named,
149
- "worktrees.remove": owner("worktree", "id"),
150
- "worktrees.setupLog": owner("worktree", "id"),
151
- "worktrees.stopSetup": owner("worktree", "id"),
152
- "worktrees.pullRequest": owner("worktree", "id"),
153
- "terminal.write": owner("terminal", "id"),
154
- "terminal.resize": owner("terminal", "id"),
155
- "terminal.close": owner("terminal", "id"),
156
- "terminal.attach": owner("terminal", "id"),
157
- "automations.update": owner("automation", "id"),
158
- "automations.delete": owner("automation", "id"),
159
- "automations.runNow": owner("automation", "id"),
160
- "automations.runs": owner("automation", "id"),
161
- "automations.webhookUrl": owner("automation", "id"),
162
- "approvals.respond": owner("request", "requestId"),
163
- "questions.respond": owner("request", "requestId"),
164
- "secrets.respond": owner("request", "requestId"),
165
- "git.log": root,
166
- "git.show": root,
167
- "fs.list": root,
168
- "fs.read": root,
169
- "fs.preview": root,
170
- "fs.write": root,
171
- "fs.watch": root,
172
- "vm.screen.send": owner("stream", "streamId"),
173
- "vm.screen.close": owner("stream", "streamId")
174
- };
175
32
  const require$1 = createRequire(import.meta.url);
176
33
  const notificationPermission = sync(() => {
177
34
  if (process.platform !== "darwin") return "unknown";
@@ -281,6 +138,12 @@ const desktopCalls = (window) => ({
281
138
  if (window) bringToFront(window);
282
139
  }),
283
140
  reveal: (path) => sync(() => shell.showItemInFolder(path)),
141
+ openExternal: (url) => {
142
+ const allowed = externalUrl(url);
143
+ return allowed === null ? void_ : tryPromise(() => shell.openExternal(allowed)).pipe(
144
+ catch_((error) => logWarning("could not open the browser", error))
145
+ );
146
+ },
284
147
  openers: listOpeners,
285
148
  openWith,
286
149
  pickFolder: map(
@@ -298,38 +161,6 @@ const desktopCalls = (window) => ({
298
161
  const untrustedSender = {
299
162
  error: { tag: "UntrustedSender", message: "RPC is only available to the HinaCode window" }
300
163
  };
301
- const WindowCall = Struct({ ...RpcCall.fields, environment: optional(String$1) });
302
- const decodeWindowCall = decodeUnknownOption(WindowCall);
303
- const payloadId = (payload, key) => {
304
- const id = typeof payload === "object" && payload !== null ? payload[key] : void 0;
305
- return typeof id === "string" ? id : void 0;
306
- };
307
- const inlineLocalAttachment = (method, payload) => method !== "attachments.stage" ? succeed(payload) : decodeUnknownEffect(RpcMethods[method].request)(payload).pipe(
308
- flatMap(
309
- (request) => "path" in request.source ? map(inlineSource(request.source.path), (source) => ({ ...request, source })) : succeed(request)
310
- )
311
- );
312
- const route = (raw, desktop) => gen(function* () {
313
- const decoded = getOrUndefined(decodeWindowCall(raw));
314
- if (decoded === void 0) return yield* dispatch(raw, desktop);
315
- const environments = yield* Environments;
316
- const { method, payload, environment } = decoded;
317
- const where = routes[method];
318
- const owned = where.to === "owner" ? payloadId(payload, where.key) : void 0;
319
- const target = where.to === "named" ? environment : where.to === "owner" && owned !== void 0 ? environments.owner(where.entity, owned) : void 0;
320
- if (target !== void 0) {
321
- return yield* inlineLocalAttachment(method, payload).pipe(
322
- flatMap((forwarded) => environments.forward(target, { method, payload: forwarded })),
323
- catch_((error) => succeed({ error: { tag: error._tag, message: error.message } }))
324
- );
325
- }
326
- if (where.to !== "all") return yield* dispatch(raw, desktop);
327
- const [local, clouds] = yield* all$1([dispatch(raw, desktop), environments.gather({ method, payload })], {
328
- concurrency: "unbounded"
329
- });
330
- if ("error" in local || !Array.isArray(local.result)) return local;
331
- return { result: [...local.result, ...clouds] };
332
- });
333
164
  const registerIpc = (runtime, appUrl2) => {
334
165
  ipcMain.handle(
335
166
  RPC_CHANNEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hinacode",
3
- "version": "0.1.0-alpha.17",
3
+ "version": "0.2.0-alpha.1",
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,14 +40,17 @@
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
- "@muse-code/sdk": "1.4.7",
46
+ "@muse-code/sdk": "1.4.13",
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",
50
52
  "pele": "1.9.0",
53
+ "playwright": "1.64.0",
51
54
  "qrcode": "^1.5.4",
52
55
  "ws": "8.22.0"
53
56
  },
@@ -82,6 +85,7 @@
82
85
  "@wterm/dom": "0.5.4",
83
86
  "@wterm/ghostty": "0.5.4",
84
87
  "babel-plugin-react-compiler": "1.0.0",
88
+ "chrono-node": "2.10.3",
85
89
  "class-variance-authority": "^0.7.1",
86
90
  "cn": "^0.4.0",
87
91
  "electron": "44.9.3",
@@ -92,6 +96,7 @@
92
96
  "node-gyp": "12.2.0",
93
97
  "oxfmt": "0.72.0",
94
98
  "oxlint": "1.87.0",
99
+ "oxlint-plugin-hinacode": "workspace:*",
95
100
  "oxlint-plugin-react-doctor": "0.9.17",
96
101
  "playwright-bdd": "9.2.1",
97
102
  "react": "19.3.0",