@obrain/cli 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -34
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -41923,11 +41923,12 @@ var startGatewayDaemon = async (gatewayUrl) => {
41923
41923
  if (config.daemon?.pid && isPidAlive(config.daemon.pid)) {
41924
41924
  return config.daemon.pid;
41925
41925
  }
41926
- const executable = process.argv[0];
41927
41926
  const script = process.argv[1];
41927
+ if (!script) {
41928
+ throw new Error("Unable to determine CLI entrypoint for daemon startup.");
41929
+ }
41928
41930
  const child = Bun.spawn({
41929
41931
  cmd: [
41930
- executable,
41931
41932
  script,
41932
41933
  "daemon",
41933
41934
  "connect",
@@ -41939,6 +41940,13 @@ var startGatewayDaemon = async (gatewayUrl) => {
41939
41940
  stderr: "ignore",
41940
41941
  env: process.env
41941
41942
  });
41943
+ const startupResult = await Promise.race([
41944
+ child.exited.then((code) => ({ type: "exited", code })),
41945
+ Bun.sleep(150).then(() => ({ type: "running" }))
41946
+ ]);
41947
+ if (startupResult.type === "exited") {
41948
+ throw new Error(`Gateway daemon exited during startup with code ${startupResult.code}.`);
41949
+ }
41942
41950
  if (typeof child.unref === "function") {
41943
41951
  child.unref?.();
41944
41952
  }
@@ -70853,34 +70861,7 @@ var listAgentCommand = {
70853
70861
  }
70854
70862
  };
70855
70863
 
70856
- // src/lib/cli.ts
70857
- import { createInterface } from "readline";
70858
- var prompt = async (question) => {
70859
- const rl = createInterface({ input: process.stdin, output: process.stdout });
70860
- const answer = await new Promise((resolve6) => {
70861
- rl.question(question, (value) => resolve6(value));
70862
- });
70863
- rl.close();
70864
- return answer.trim();
70865
- };
70866
- var openBrowser = (url2) => {
70867
- const platform = process.platform;
70868
- if (platform === "darwin") {
70869
- Bun.spawn(["open", url2]);
70870
- return;
70871
- }
70872
- if (platform === "win32") {
70873
- Bun.spawn(["cmd", "/c", "start", url2]);
70874
- return;
70875
- }
70876
- Bun.spawn(["xdg-open", url2]);
70877
- };
70878
-
70879
70864
  // src/lib/command-helpers.ts
70880
- var isConfirmationAccepted = (input) => {
70881
- const normalized = input.trim().toLowerCase();
70882
- return normalized === "y" || normalized === "yes";
70883
- };
70884
70865
  var isJwtTokenActive = (token, now = Date.now()) => {
70885
70866
  if (!token) {
70886
70867
  return false;
@@ -70930,11 +70911,6 @@ var registerFromCardUrl = async (cardUrl) => {
70930
70911
  const decoded = jwtDecode(config2.token);
70931
70912
  const userId = decoded.sub ?? "unknown";
70932
70913
  printAgentCardPreview(localUrl, card);
70933
- const confirmation = await prompt(`Register this agent to ${gatewayUrl}? (y/N): `);
70934
- if (!isConfirmationAccepted(confirmation)) {
70935
- console.log("Registration cancelled.");
70936
- process.exit(0);
70937
- }
70938
70914
  const agent = await upsertRemoteAgent(config2, {
70939
70915
  deviceId: config2.deviceId,
70940
70916
  localUrl
@@ -71328,6 +71304,20 @@ var exchangeBearerForJwt = async ({
71328
71304
  return data.token;
71329
71305
  };
71330
71306
 
71307
+ // src/lib/cli.ts
71308
+ var openBrowser = (url2) => {
71309
+ const platform = process.platform;
71310
+ if (platform === "darwin") {
71311
+ Bun.spawn(["open", url2]);
71312
+ return;
71313
+ }
71314
+ if (platform === "win32") {
71315
+ Bun.spawn(["cmd", "/c", "start", url2]);
71316
+ return;
71317
+ }
71318
+ Bun.spawn(["xdg-open", url2]);
71319
+ };
71320
+
71331
71321
  // src/lib/devices/registry.ts
71332
71322
  var createRemoteDevice = async (config2, trpcUrlOverride) => {
71333
71323
  return getTrpcClient(config2, trpcUrlOverride).userDevice.create.mutate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obrain/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"