byollm 0.1.0-alpha.97 → 0.1.0-alpha.98

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  > [!WARNING]
2
- > **Alpha (`0.1.0-alpha.97`) — under active development. Don't use this yet.**
2
+ > **Alpha (`0.1.0-alpha.98`) — under active development. Don't use this yet.**
3
3
  >
4
4
  > Install it deliberately: `npx byollm@latest`, or `npm install byollm@latest`.
5
5
  >
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  main
4
- } from "./chunk-R3WK5X6Q.js";
4
+ } from "./chunk-JCLM24WC.js";
5
5
 
6
6
  // src/bin.ts
7
7
  process.exitCode = await main(process.argv.slice(2));
@@ -4985,9 +4985,13 @@ async function openPtyShell(options) {
4985
4985
  }
4986
4986
 
4987
4987
  // src/console-agent-main.ts
4988
- import { SealedEnvelope as SealedEnvelopeSchema } from "@byollm/protocol";
4989
- var connectWebSocket = (url) => new Promise((resolve, reject) => {
4990
- const socket = new WebSocket(url);
4988
+ import {
4989
+ SealedEnvelope as SealedEnvelopeSchema,
4990
+ signRequest as signRequest2
4991
+ } from "@byollm/protocol";
4992
+ var CONSOLE_BOX_ENDPOINT = "/console/box";
4993
+ var connectWebSocket = (url, headers) => new Promise((resolve, reject) => {
4994
+ const socket = new WebSocket(url, { headers });
4991
4995
  socket.addEventListener("open", () => {
4992
4996
  resolve({
4993
4997
  send: (text) => {
@@ -5019,7 +5023,17 @@ async function runConsoleAgent(options) {
5019
5023
  cwd: options.cwd,
5020
5024
  env: options.env
5021
5025
  });
5022
- const socket = await (options.connect ?? connectWebSocket)(options.url);
5026
+ const signed = signRequest2(options.keys, {
5027
+ endpoint: CONSOLE_BOX_ENDPOINT,
5028
+ runnerId: options.runnerId,
5029
+ issuedAt: (options.now ?? Date.now)(),
5030
+ body: options.sessionId
5031
+ });
5032
+ const socket = await (options.connect ?? connectWebSocket)(options.url, {
5033
+ "x-byollm-runner": signed.runnerId,
5034
+ "x-byollm-issued-at": String(signed.issuedAt),
5035
+ "x-byollm-signature": signed.signature
5036
+ });
5023
5037
  const session = consoleSession({
5024
5038
  sessionId: options.sessionId,
5025
5039
  deadlineAt: options.deadlineAt,
@@ -5099,10 +5113,10 @@ var ConsoleAgentSpec = z5.object({
5099
5113
  }).strict();
5100
5114
 
5101
5115
  // src/console-listen.ts
5102
- import { signRequest as signRequest2 } from "@byollm/protocol";
5116
+ import { signRequest as signRequest3 } from "@byollm/protocol";
5103
5117
  var CONSOLE_DEVICE_ENDPOINT = "/console/device";
5104
5118
  var deviceHeaders = (keys, runnerId, now) => {
5105
- const signed = signRequest2(keys, {
5119
+ const signed = signRequest3(keys, {
5106
5120
  endpoint: CONSOLE_DEVICE_ENDPOINT,
5107
5121
  runnerId,
5108
5122
  issuedAt: now,
@@ -8888,10 +8902,19 @@ async function commandConsoleAgent(paths, args, io) {
8888
8902
  runnerId: paired.runnerId,
8889
8903
  keys,
8890
8904
  run: (announcement) => runConsoleAgent({
8891
- url: `${paired.origin.replace(/^http/, "ws")}/console/box?session=${announcement.sessionId}`,
8905
+ /* The endpoint from one definition, shared with the signer that
8906
+ has to name it identically — a URL built here and a signature
8907
+ built there, disagreeing by a character, is a 401 nobody can
8908
+ read. */
8909
+ url: `${paired.origin.replace(/^http/, "ws")}${CONSOLE_BOX_ENDPOINT}?session=${announcement.sessionId}`,
8892
8910
  sessionId: announcement.sessionId,
8893
8911
  deadlineAt: announcement.deadlineAt,
8894
8912
  keys,
8913
+ /* The data door is authenticated too, and signs over the SESSION —
8914
+ a signature captured from one cannot be replayed to join
8915
+ another. Without this the dial is refused 401 before the
8916
+ handshake, which is what attempt six hit. */
8917
+ runnerId: paired.runnerId,
8895
8918
  browser: announcement.browser,
8896
8919
  command: process.env["BYOLLM_CONSOLE_SHELL"] ?? "/bin/sh",
8897
8920
  args: [],
@@ -8923,12 +8946,22 @@ async function commandConsoleAgent(paths, args, io) {
8923
8946
  io.err("That session description is not one this agent understands.\n");
8924
8947
  return 2;
8925
8948
  }
8949
+ const agentPairings = new Pairings(paths.pairings);
8950
+ await agentPairings.load();
8951
+ const agentPaired = agentPairings.list()[0];
8952
+ if (agentPaired === void 0) {
8953
+ io.err(
8954
+ "byollm console-agent cannot join a console: this device is not paired.\nThe hub will not accept an unsigned connection. Pair it first with `byollm connect`.\n"
8955
+ );
8956
+ return 1;
8957
+ }
8926
8958
  try {
8927
8959
  const why = await runConsoleAgent({
8928
8960
  url: session.data.url,
8929
8961
  sessionId: session.data.sessionId,
8930
8962
  deadlineAt: session.data.deadlineAt,
8931
8963
  keys,
8964
+ runnerId: agentPaired.runnerId,
8932
8965
  browser: session.data.browser,
8933
8966
  command: session.data.shell.command,
8934
8967
  args: session.data.shell.args,
@@ -10503,7 +10536,7 @@ async function exists(path) {
10503
10536
  }
10504
10537
 
10505
10538
  // src/index.ts
10506
- var DAEMON_VERSION = "0.1.0-alpha.97";
10539
+ var DAEMON_VERSION = "0.1.0-alpha.98";
10507
10540
  function daemonVersion() {
10508
10541
  return {
10509
10542
  daemon: DAEMON_VERSION,
@@ -10562,4 +10595,4 @@ export {
10562
10595
  runCli,
10563
10596
  main
10564
10597
  };
10565
- //# sourceMappingURL=chunk-R3WK5X6Q.js.map
10598
+ //# sourceMappingURL=chunk-JCLM24WC.js.map