lody 0.50.0 → 0.50.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.
Files changed (2) hide show
  1. package/dist/index.js +40 -11
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -36821,7 +36821,7 @@ Mongoose Error Code: ${error2.code}` : ""}`
36821
36821
  return client;
36822
36822
  }
36823
36823
  const name = "lody";
36824
- const version$4 = "0.50.0";
36824
+ const version$4 = "0.50.1";
36825
36825
  const description$1 = "Lody Agent CLI tool for managing remote command execution";
36826
36826
  const type$2 = "module";
36827
36827
  const main$3 = "dist/index.js";
@@ -127644,9 +127644,11 @@ $mem | ConvertTo-Json -Compress
127644
127644
  return;
127645
127645
  }
127646
127646
  const requesterUserId = nextUserTurn.userId ?? freshMeta.userId;
127647
+ const localProjectId = freshMeta.project?.kind === "local" ? freshMeta.project.localProjectId : void 0;
127647
127648
  const access = await this.deps.canUseMachine({
127648
127649
  sessionId,
127649
- requesterUserId
127650
+ requesterUserId,
127651
+ localProjectId
127650
127652
  });
127651
127653
  if (!access.allowed) {
127652
127654
  await this.markDispatchAccessDenied(sessionId, sessionDoc, nextUserTurn.id, access.reason);
@@ -127668,6 +127670,8 @@ $mem | ConvertTo-Json -Compress
127668
127670
  return "This machine is not registered for workspace access.";
127669
127671
  case "not_visible":
127670
127672
  return "This machine is private to its owner.";
127673
+ case "project_not_shared":
127674
+ return "This local project is not shared with the team.";
127671
127675
  case "access_unavailable":
127672
127676
  return "Machine access could not be verified.";
127673
127677
  case "cli_token_invalid":
@@ -128499,7 +128503,8 @@ $mem | ConvertTo-Json -Compress
128499
128503
  reason: _enum$1([
128500
128504
  "requester_not_member",
128501
128505
  "machine_not_registered",
128502
- "not_visible"
128506
+ "not_visible",
128507
+ "project_not_shared"
128503
128508
  ])
128504
128509
  })
128505
128510
  ]);
@@ -128551,15 +128556,30 @@ $mem | ConvertTo-Json -Compress
128551
128556
  });
128552
128557
  return RegisterMachineAccessResultSchema.parse(raw);
128553
128558
  }
128559
+ const LEGACY_LOCAL_PROJECT_ID_VALIDATOR_ERROR = /ArgumentValidationError[\s\S]*extra field `localProjectId`/;
128554
128560
  async function canUseMachineForCliToken(input2) {
128555
128561
  const client = createAuthConvexClient();
128556
- const raw = await client.query(api.machines.canUseMachineFromCliToken, {
128562
+ const baseArgs = {
128557
128563
  cliToken: input2.token,
128558
128564
  workspaceId: input2.workspaceId,
128559
128565
  machineId: input2.machineId,
128560
128566
  requesterUserId: input2.requesterUserId
128561
- });
128562
- return MachineAccessCheckResultSchema.parse(raw);
128567
+ };
128568
+ try {
128569
+ const raw = await client.query(api.machines.canUseMachineFromCliToken, {
128570
+ ...baseArgs,
128571
+ ...input2.localProjectId !== void 0 ? {
128572
+ localProjectId: input2.localProjectId
128573
+ } : {}
128574
+ });
128575
+ return MachineAccessCheckResultSchema.parse(raw);
128576
+ } catch (error2) {
128577
+ if (input2.localProjectId !== void 0 && error2 instanceof Error && LEGACY_LOCAL_PROJECT_ID_VALIDATOR_ERROR.test(error2.message)) {
128578
+ const raw = await client.query(api.machines.canUseMachineFromCliToken, baseArgs);
128579
+ return MachineAccessCheckResultSchema.parse(raw);
128580
+ }
128581
+ throw error2;
128582
+ }
128563
128583
  }
128564
128584
  const HTTP_HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
128565
128585
  "connection",
@@ -130705,13 +130725,14 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
130705
130725
  workspaceId: this.workspaceId,
130706
130726
  workspaceDocument: this.workspaceDocument,
130707
130727
  executionService: this.executionService,
130708
- canUseMachine: async ({ requesterUserId, sessionId }) => {
130728
+ canUseMachine: async ({ requesterUserId, sessionId, localProjectId }) => {
130709
130729
  try {
130710
130730
  return await canUseMachineForCliToken({
130711
130731
  token: this.token,
130712
130732
  workspaceId: this.workspaceId,
130713
130733
  machineId: this.machineId,
130714
- requesterUserId
130734
+ requesterUserId,
130735
+ localProjectId
130715
130736
  });
130716
130737
  } catch (error2) {
130717
130738
  const message = formatErrorMessage(error2);
@@ -143674,6 +143695,7 @@ Received ${signal}, shutting down gracefully...` : "\nShutting down gracefully..
143674
143695
  }
143675
143696
  const ELECTRON_BOOTSTRAP_ENV = "LODY_ELECTRON_BOOTSTRAP";
143676
143697
  const ELECTRON_SESSION_TOKEN_ENV = "LODY_ELECTRON_SESSION_TOKEN";
143698
+ const ELECTRON_SESSION_USER_ID_ENV = "LODY_ELECTRON_SESSION_USER_ID";
143677
143699
  const EXIT_CODE_ALREADY_RUNNING = 3;
143678
143700
  function logCliDetectionResults(logger2, availability) {
143679
143701
  logger2.debug("Local agent auth detection results:");
@@ -143715,6 +143737,7 @@ Received ${signal}, shutting down gracefully...` : "\nShutting down gracefully..
143715
143737
  runtimeStateReporter.setStartupStage("bootstrap");
143716
143738
  const electronBootstrapEnabled = process.env[ELECTRON_BOOTSTRAP_ENV] === "1";
143717
143739
  const electronSessionToken = process.env[ELECTRON_SESSION_TOKEN_ENV]?.trim();
143740
+ const electronSessionUserId = process.env[ELECTRON_SESSION_USER_ID_ENV]?.trim() || null;
143718
143741
  const providedAuth = options.auth?.trim();
143719
143742
  const cliAvailability = {
143720
143743
  claude: checkClaude(),
@@ -143783,13 +143806,19 @@ Received ${signal}, shutting down gracefully...` : "\nShutting down gracefully..
143783
143806
  } else if (existingAuth) {
143784
143807
  logger2.debug("Found existing authentication, checking validity...");
143785
143808
  const validation2 = await authClient.validateToken(existingAuth.token);
143786
- if (validation2.valid) {
143809
+ const existingUserId = validation2.valid ? validation2.userId ?? existingAuth.user.id : null;
143810
+ const electronUserMismatch = !!electronSessionToken && electronSessionUserId !== null && existingUserId !== null && existingUserId !== electronSessionUserId;
143811
+ if (validation2.valid && existingUserId && !electronUserMismatch) {
143787
143812
  token2 = existingAuth.token;
143788
- userId = validation2.userId ?? existingAuth.user.id;
143813
+ userId = existingUserId;
143789
143814
  machineId = existingAuth.machine.machineId;
143790
143815
  machineName = defaultMachineName;
143791
143816
  } else {
143792
- logger2.warn("Existing authentication is invalid.");
143817
+ if (electronUserMismatch) {
143818
+ logger2.warn("Existing CLI credentials belong to a different account than the desktop session \u2014 re-authenticating.");
143819
+ } else {
143820
+ logger2.warn("Existing authentication is invalid.");
143821
+ }
143793
143822
  const bootstrap = await completeBootstrapLogin();
143794
143823
  if (bootstrap) {
143795
143824
  token2 = bootstrap.token;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lody",
3
- "version": "0.50.0",
3
+ "version": "0.50.1",
4
4
  "description": "Lody Agent CLI tool for managing remote command execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -74,10 +74,10 @@
74
74
  "ws": "^8.18.3",
75
75
  "zod": "^4.1.5",
76
76
  "@lody/cli-supervisor": "0.0.1",
77
+ "@lody/convex": "0.0.1",
77
78
  "@lody/loro-streams-rpc": "0.0.1",
78
79
  "@lody/shared": "0.0.1",
79
- "loro-code": "0.0.1",
80
- "@lody/convex": "0.0.1"
80
+ "loro-code": "0.0.1"
81
81
  },
82
82
  "files": [
83
83
  "dist",