usebeeline 0.0.1 → 0.0.2

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
@@ -3,11 +3,11 @@
3
3
  Connect a supported coding-agent harness to Beeline:
4
4
 
5
5
  ```sh
6
- npx usebeeline connect
6
+ npx usebeeline connect <PAIRING_CODE_FROM_THE_APP>
7
7
  ```
8
8
 
9
- The package also exposes a `beeline` bin alias. The connect command opens a
10
- short-lived browser approval, installs the signed current daemon bundle into
9
+ The package also exposes a `beeline` bin alias. The connect command uses the
10
+ short-lived code minted by the Beeline app, installs the signed current daemon bundle into
11
11
  the canonical `~/.local` layout, and starts the supervised user service.
12
12
 
13
13
  The wizard asks exactly for the harness, any required provider credential, the
@@ -1264,18 +1264,18 @@ function validateTableBytes(numPoints, fpBytes) {
1264
1264
  if (bytes > TABLE_BYTES_MAX)
1265
1265
  throw new Error("invalid window size: table would need ~" + Math.ceil(bytes / 2 ** 20) + " MiB, max " + TABLE_BYTES_MAX / 2 ** 20 + " MiB");
1266
1266
  }
1267
- function probeRandomBytes(randomBytes8, length) {
1268
- if (randomBytes8 === void 0)
1267
+ function probeRandomBytes(randomBytes7, length) {
1268
+ if (randomBytes7 === void 0)
1269
1269
  return void 0;
1270
- afunction(randomBytes8, "randomBytes");
1270
+ afunction(randomBytes7, "randomBytes");
1271
1271
  try {
1272
- const probe = randomBytes8(length);
1272
+ const probe = randomBytes7(length);
1273
1273
  if (!isBytes2(probe) || probe.length !== length)
1274
1274
  return void 0;
1275
1275
  } catch {
1276
1276
  return void 0;
1277
1277
  }
1278
- return randomBytes8;
1278
+ return randomBytes7;
1279
1279
  }
1280
1280
  function validateMSMPoints(points, c2) {
1281
1281
  aarray(points, "points");
@@ -1431,9 +1431,9 @@ var init_curve = __esm({
1431
1431
  baseCanBeBlinded;
1432
1432
  bits;
1433
1433
  // Parametrized with a given Point class (not individual point)
1434
- constructor(Point, randomBytes8) {
1434
+ constructor(Point, randomBytes7) {
1435
1435
  validatePointCons(Point);
1436
- this.randomBytes = probeRandomBytes(randomBytes8, BLIND_BYTES);
1436
+ this.randomBytes = probeRandomBytes(randomBytes7, BLIND_BYTES);
1437
1437
  this.Point = Point;
1438
1438
  this.BASE = Point.BASE;
1439
1439
  this.ZERO = Point.ZERO;
@@ -1666,7 +1666,7 @@ function weierstrass(params, extraOpts = {}) {
1666
1666
  randomBytes: "function"
1667
1667
  });
1668
1668
  const { endo, allowInfinityPoint } = extraOpts;
1669
- const randomBytes8 = extraOpts.randomBytes === void 0 ? randomBytes2 : extraOpts.randomBytes;
1669
+ const randomBytes7 = extraOpts.randomBytes === void 0 ? randomBytes2 : extraOpts.randomBytes;
1670
1670
  if (endo) {
1671
1671
  if (!Fp.is0(CURVE.a) || typeof endo.beta !== "bigint" || !Array.isArray(endo.basises)) {
1672
1672
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
@@ -2078,7 +2078,7 @@ function weierstrass(params, extraOpts = {}) {
2078
2078
  }
2079
2079
  }
2080
2080
  const normalize3 = (points) => normalizeZ(Point, points);
2081
- const wnaf = new ScalarMultiplier(Point, randomBytes8);
2081
+ const wnaf = new ScalarMultiplier(Point, randomBytes7);
2082
2082
  if (wnaf.bits >= 6)
2083
2083
  Point.BASE.precompute(6);
2084
2084
  Object.freeze(Point.prototype);
@@ -4102,7 +4102,7 @@ function ecdsa2(Point, hash, ecdsaOpts = {}) {
4102
4102
  bits2int_modN: "function"
4103
4103
  });
4104
4104
  ecdsaOpts = Object.assign({}, ecdsaOpts);
4105
- const randomBytes8 = ecdsaOpts.randomBytes || randomBytes3;
4105
+ const randomBytes7 = ecdsaOpts.randomBytes || randomBytes3;
4106
4106
  const hmac2 = ecdsaOpts.hmac || ((key, msg) => hmac(hash, key, msg));
4107
4107
  const { Fp, Fn } = Point;
4108
4108
  const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
@@ -4244,7 +4244,7 @@ function ecdsa2(Point, hash, ecdsaOpts = {}) {
4244
4244
  throw new Error("invalid private key");
4245
4245
  const seedArgs = [int2octets(d), int2octets(h1int)];
4246
4246
  if (extraEntropy != null && extraEntropy !== false) {
4247
- const e = extraEntropy === true ? randomBytes8(lengths.secretKey) : extraEntropy;
4247
+ const e = extraEntropy === true ? randomBytes7(lengths.secretKey) : extraEntropy;
4248
4248
  seedArgs.push(abytes3(e, void 0, "extraEntropy"));
4249
4249
  }
4250
4250
  const seed = concatBytes3(...seedArgs);
@@ -11338,7 +11338,7 @@ var require_websocket = __commonJS({
11338
11338
  var http = __require("http");
11339
11339
  var net = __require("net");
11340
11340
  var tls = __require("tls");
11341
- var { randomBytes: randomBytes8, createHash: createHash16 } = __require("crypto");
11341
+ var { randomBytes: randomBytes7, createHash: createHash15 } = __require("crypto");
11342
11342
  var { Duplex, Readable } = __require("stream");
11343
11343
  var { URL: URL2 } = __require("url");
11344
11344
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -11876,7 +11876,7 @@ var require_websocket = __commonJS({
11876
11876
  }
11877
11877
  }
11878
11878
  const defaultPort = isSecure ? 443 : 80;
11879
- const key = randomBytes8(16).toString("base64");
11879
+ const key = randomBytes7(16).toString("base64");
11880
11880
  const request = isSecure ? https.request : http.request;
11881
11881
  const protocolSet = /* @__PURE__ */ new Set();
11882
11882
  let perMessageDeflate;
@@ -12006,7 +12006,7 @@ var require_websocket = __commonJS({
12006
12006
  abortHandshake(websocket, socket, "Invalid Upgrade header");
12007
12007
  return;
12008
12008
  }
12009
- const digest2 = createHash16("sha1").update(key + GUID).digest("base64");
12009
+ const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
12010
12010
  if (res.headers["sec-websocket-accept"] !== digest2) {
12011
12011
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
12012
12012
  return;
@@ -12375,7 +12375,7 @@ var require_websocket_server = __commonJS({
12375
12375
  var EventEmitter2 = __require("events");
12376
12376
  var http = __require("http");
12377
12377
  var { Duplex } = __require("stream");
12378
- var { createHash: createHash16 } = __require("crypto");
12378
+ var { createHash: createHash15 } = __require("crypto");
12379
12379
  var extension2 = require_extension();
12380
12380
  var PerMessageDeflate2 = require_permessage_deflate();
12381
12381
  var subprotocol2 = require_subprotocol();
@@ -12682,7 +12682,7 @@ var require_websocket_server = __commonJS({
12682
12682
  );
12683
12683
  }
12684
12684
  if (this._state > RUNNING) return abortHandshake(socket, 503);
12685
- const digest2 = createHash16("sha1").update(key + GUID).digest("base64");
12685
+ const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
12686
12686
  const headers2 = [
12687
12687
  "HTTP/1.1 101 Switching Protocols",
12688
12688
  "Upgrade: websocket",
@@ -22029,11 +22029,11 @@ function parseUpdateManifest(raw, platform) {
22029
22029
  }
22030
22030
  const bundle = entry;
22031
22031
  const file = typeof bundle.file === "string" ? bundle.file : "";
22032
- const sha2565 = typeof bundle.sha256 === "string" ? bundle.sha256.toLowerCase() : "";
22032
+ const sha2564 = typeof bundle.sha256 === "string" ? bundle.sha256.toLowerCase() : "";
22033
22033
  if (!file || !/^[a-z0-9][a-z0-9._-]*$/i.test(file)) {
22034
22034
  throw new Error(`update manifest names an unusable bundle file: ${JSON.stringify(bundle.file)}`);
22035
22035
  }
22036
- if (!/^[0-9a-f]{64}$/.test(sha2565)) {
22036
+ if (!/^[0-9a-f]{64}$/.test(sha2564)) {
22037
22037
  throw new Error(`update manifest carries no usable sha256 for ${platform}`);
22038
22038
  }
22039
22039
  const sourceCommit = typeof bundle.commit === "string" && bundle.commit ? bundle.commit : typeof manifest.sourceCommit === "string" ? manifest.sourceCommit : void 0;
@@ -22045,7 +22045,7 @@ function parseUpdateManifest(raw, platform) {
22045
22045
  bundles,
22046
22046
  bundle: {
22047
22047
  file,
22048
- sha256: sha2565,
22048
+ sha256: sha2564,
22049
22049
  ...typeof bundle.bytes === "number" ? { bytes: bundle.bytes } : {},
22050
22050
  ...sourceCommit ? { commit: sourceCommit } : {},
22051
22051
  ...version ? { version } : {},
@@ -24397,10 +24397,10 @@ function parseArtifact(value) {
24397
24397
  const artifactId = token(input.artifactId);
24398
24398
  const revision = integer(input.revision, 1);
24399
24399
  const eventId = typeof input.eventId === "string" && HEX_64.test(input.eventId) ? input.eventId : void 0;
24400
- const sha2565 = typeof input.sha256 === "string" && SHA_256.test(input.sha256) ? input.sha256 : void 0;
24401
- if (!artifactId || revision === void 0 || !eventId || !sha2565)
24400
+ const sha2564 = typeof input.sha256 === "string" && SHA_256.test(input.sha256) ? input.sha256 : void 0;
24401
+ if (!artifactId || revision === void 0 || !eventId || !sha2564)
24402
24402
  return void 0;
24403
- return { artifactId, revision, eventId, sha256: sha2565 };
24403
+ return { artifactId, revision, eventId, sha256: sha2564 };
24404
24404
  }
24405
24405
  function parseArtifacts(value) {
24406
24406
  if (!Array.isArray(value) || value.length === 0 || value.length > MAX_PERMISSION_LIST_ITEMS) {
@@ -30168,7 +30168,7 @@ function normalizeAttachmentReference(value) {
30168
30168
  return null;
30169
30169
  const thumbnailUrl = value.thumbnailUrl ? httpUrl2(value.thumbnailUrl) : void 0;
30170
30170
  const previewUrl = value.previewUrl ? httpUrl2(value.previewUrl) : void 0;
30171
- const sha2565 = value.sha256?.toLowerCase();
30171
+ const sha2564 = value.sha256?.toLowerCase();
30172
30172
  const width = cleanSize(value.width ?? 0);
30173
30173
  const height = cleanSize(value.height ?? 0);
30174
30174
  return {
@@ -30177,7 +30177,7 @@ function normalizeAttachmentReference(value) {
30177
30177
  mimeType,
30178
30178
  size,
30179
30179
  ...previewUrl ? { previewUrl } : {},
30180
- ...sha2565 && /^[0-9a-f]{64}$/.test(sha2565) ? { sha256: sha2565 } : {},
30180
+ ...sha2564 && /^[0-9a-f]{64}$/.test(sha2564) ? { sha256: sha2564 } : {},
30181
30181
  ...thumbnailUrl ? { thumbnailUrl } : {},
30182
30182
  ...value.width !== void 0 && width !== void 0 && width > 0 ? { width } : {},
30183
30183
  ...value.height !== void 0 && height !== void 0 && height > 0 ? { height } : {}
@@ -55857,7 +55857,6 @@ async function runPairCommand(args, llmEnvFile, agentPrivateKey) {
55857
55857
 
55858
55858
  // apps/body/dist/connect-command.js
55859
55859
  import { spawn as spawn12 } from "node:child_process";
55860
- import { createHash as createHash15, randomBytes as randomBytes7 } from "node:crypto";
55861
55860
  import { chmod as chmod7, mkdir as mkdir18, readFile as readFile13, unlink as unlink5, writeFile as writeFile12 } from "node:fs/promises";
55862
55861
  import { dirname as dirname16, resolve as resolve37 } from "node:path";
55863
55862
  import { stdin as stdin4, stdout as stdout5 } from "node:process";
@@ -55999,9 +55998,6 @@ async function collectConnectWizard(prompts = clackPrompts, loadModels = loadCon
55999
55998
  soul: soul.trim()
56000
55999
  };
56001
56000
  }
56002
- function sha2564(value) {
56003
- return createHash15("sha256").update(value).digest("hex");
56004
- }
56005
56001
  async function jsonRequest(url, body, fetchImpl) {
56006
56002
  const response = await fetchImpl(url, {
56007
56003
  method: "POST",
@@ -56015,41 +56011,15 @@ async function jsonRequest(url, body, fetchImpl) {
56015
56011
  }
56016
56012
  return response.json();
56017
56013
  }
56018
- async function openBrowser(url) {
56019
- const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
56020
- const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
56021
- await new Promise((resolveOpen, rejectOpen) => {
56022
- const child = spawn12(command, args, { detached: true, stdio: "ignore" });
56023
- child.once("error", rejectOpen);
56024
- child.once("spawn", () => {
56025
- child.unref();
56026
- resolveOpen();
56027
- });
56028
- });
56029
- }
56030
- async function pollDeviceGrant(input) {
56031
- const deadline = Date.now() + input.start.expires_in * 1e3;
56032
- while (Date.now() < deadline) {
56033
- const response = await input.fetchImpl(`${input.baseUrl}/auth/device/token`, {
56034
- method: "POST",
56035
- headers: { "content-type": "application/json" },
56036
- body: JSON.stringify({
56037
- device_code: input.start.device_code,
56038
- code_verifier: input.verifier
56039
- }),
56040
- signal: AbortSignal.timeout(3e4)
56041
- });
56042
- if (response.status === 428) {
56043
- await new Promise((resolveWait) => setTimeout(resolveWait, input.start.interval * 1e3));
56044
- continue;
56045
- }
56046
- if (!response.ok) {
56047
- const detail = await response.json().catch(() => ({}));
56048
- throw new Error(detail.message ?? detail.error ?? `authorization failed (HTTP ${response.status})`);
56049
- }
56050
- return response.json();
56051
- }
56052
- throw new Error("browser authorization expired; run `npx usebeeline connect` again");
56014
+ function requestConnectGrant(baseUrl, pairingCode, selection, fetchImpl) {
56015
+ return jsonRequest(`${baseUrl}/auth/agent/connect`, {
56016
+ pairing_code: pairingCode.trim().toUpperCase(),
56017
+ harness: selection.harness,
56018
+ ...selection.provider ? { provider: selection.provider } : {},
56019
+ model: selection.model,
56020
+ soul: selection.soul,
56021
+ agent_name: selection.name
56022
+ }, fetchImpl);
56053
56023
  }
56054
56024
  async function installCurrentRelease(fetchImpl) {
56055
56025
  const manifestUrl = resolveManifestUrl(process.env);
@@ -56136,29 +56106,19 @@ async function brassSpinner(message2, action) {
56136
56106
  throw error;
56137
56107
  }
56138
56108
  }
56139
- async function runConnectCommand(options = {}) {
56109
+ async function runConnectCommand(code, options = {}) {
56140
56110
  if (!stdin4.isTTY || !stdout5.isTTY) {
56141
56111
  throw new Error("`usebeeline connect` needs an interactive terminal");
56142
56112
  }
56143
56113
  intro(brass("Beeline connect"));
56114
+ const pairingCode = code?.trim() || await clackPrompts.text({
56115
+ message: brass("Pairing code from the app"),
56116
+ validate: (value) => value.trim() ? void 0 : "Pairing code is required"
56117
+ });
56144
56118
  const selection = await collectConnectWizard();
56145
56119
  const fetchImpl = options.fetchImpl ?? fetch;
56146
56120
  const baseUrl = (process.env.BEELINE_AUTH_URL ?? "https://server.usebeeline.app").replace(/\/$/, "");
56147
- const verifier = randomBytes7(32).toString("base64url");
56148
- const start = await brassSpinner("Preparing secure sign-in\u2026", () => jsonRequest(`${baseUrl}/auth/device/connect`, {
56149
- harness: selection.harness,
56150
- ...selection.provider ? { provider: selection.provider } : {},
56151
- model: selection.model,
56152
- soul: selection.soul,
56153
- agent_name: selection.name,
56154
- code_challenge: sha2564(verifier)
56155
- }, fetchImpl));
56156
- try {
56157
- await openBrowser(start.verification_uri_complete);
56158
- } catch {
56159
- console.log(`Open this link to connect: ${start.verification_uri_complete}`);
56160
- }
56161
- const grant = await brassSpinner("Connecting to your Beeline Workspace\u2026", () => pollDeviceGrant({ baseUrl, start, verifier, fetchImpl }));
56121
+ const grant = await brassSpinner("Connecting to your Beeline Workspace\u2026", () => requestConnectGrant(baseUrl, pairingCode, selection, fetchImpl));
56162
56122
  const installedBinary = await brassSpinner("Installing the Beeline daemon\u2026", () => installCurrentRelease(fetchImpl));
56163
56123
  const llmEnvFile = await writeProviderEnv(selection, grant.agent_pubkey);
56164
56124
  const grantPath = resolve37(defaultSupervisorRoot(process.env), "beeline", "connect", `grant-${process.pid}-${Date.now()}.json`);
@@ -57200,7 +57160,7 @@ ${import_picocolors6.default.dim("Usage:")}
57200
57160
  beeline archive <subchannel-uuid> Archive subchannel
57201
57161
  beeline pair <BUZZ-XXXX-XXXX> [options] Pair an agent (optionally to this repo)
57202
57162
  and start its durable daemon
57203
- beeline connect Install and connect an agent through the browser
57163
+ beeline connect [BUZZ-XXXX-XXXX] Install and connect an app-authorized agent
57204
57164
  beeline start [agent-pubkey] Start \u2014 or RESTART when already running,
57205
57165
  stopping cleanly after in-flight work \u2014
57206
57166
  this repo's (or, outside a repo, this
@@ -57590,7 +57550,7 @@ async function main2() {
57590
57550
  return;
57591
57551
  }
57592
57552
  if (command === "connect") {
57593
- await runConnectCommand();
57553
+ await runConnectCommand(args[1]);
57594
57554
  return;
57595
57555
  }
57596
57556
  if (command === "connect-finish") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usebeeline",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Connect an AI coding agent to Beeline with one command.",
5
5
  "repository": {
6
6
  "type": "git",