@ricsam/r5d-worker 0.0.31 → 0.0.33

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
@@ -15,6 +15,8 @@ The worker uses the existing `r5dctl` config file and accepts `R5D_WORKER_TOKEN`
15
15
 
16
16
  Web shells and agent shell commands receive a server-issued `r5dctl` credential automatically. The credential is scoped to the signed-in user and revoked when the shell or command finishes, so commands such as `r5dctl auth status` do not require a separate login on the worker host.
17
17
 
18
+ When the user has signed in with GitHub, web shells and agent commands also receive that OAuth credential through `GH_TOKEN`. GitHub CLI commands such as `gh pr`, `gh issue`, and `gh workflow` therefore use the signed-in user's permissions without a separate `gh auth login` on the worker host. Signing in again refreshes the granted OAuth scopes for subsequently started commands and shells.
19
+
18
20
  Visible branch checkouts are the user/agent workbench. Their `origin` remains the connected GitHub repository for manual Git work. r5d internal sync git metadata lives separately under `~/.r5d/sync`; when a worker connects, every idle registered branch is force-synchronized from that internal remote. The same destructive sync can be requested for a live worker from User Settings.
19
21
 
20
22
  Worker labels are mandatory and unique per user. Choose labels that describe host capabilities, such as `macos`, `linux`, `ios`, or `ec2-build`.
package/dist/cjs/main.cjs CHANGED
@@ -32,6 +32,7 @@ __export(main_exports, {
32
32
  ensureVisibleGitCheckout: () => ensureVisibleGitCheckout,
33
33
  findRepositorySyncBlockers: () => findRepositorySyncBlockers,
34
34
  findWorkerFiles: () => findWorkerFiles,
35
+ githubCliEnv: () => githubCliEnv,
35
36
  grepWorkerFiles: () => grepWorkerFiles,
36
37
  isArtifactEnvPath: () => isArtifactEnvPath,
37
38
  listWorkerDirectory: () => listWorkerDirectory,
@@ -72,7 +73,7 @@ const activeProcesses = /* @__PURE__ */ new Map();
72
73
  const cancelledProcessRuns = /* @__PURE__ */ new Set();
73
74
  const activePtys = /* @__PURE__ */ new Map();
74
75
  let currentWorkerSocket = null;
75
- let containerRegistryCredential = null;
76
+ let githubCredential = null;
76
77
  let visibleGitIdentity = null;
77
78
  function defaultConfigPath() {
78
79
  return import_node_path.default.join(import_node_os.default.homedir(), ".config", "r5d", "r5dctl", "config.json");
@@ -928,8 +929,8 @@ function writeRegistryAuthFile(filePath, credential) {
928
929
  const auths = existingAuths;
929
930
  auths[credential.registry] = {
930
931
  username: credential.username,
931
- password: credential.password,
932
- auth: Buffer.from(`${credential.username}:${credential.password}`).toString("base64")
932
+ password: credential.token,
933
+ auth: Buffer.from(`${credential.username}:${credential.token}`).toString("base64")
933
934
  };
934
935
  config.auths = auths;
935
936
  import_node_fs.default.mkdirSync(import_node_path.default.dirname(filePath), { recursive: true });
@@ -937,8 +938,8 @@ function writeRegistryAuthFile(filePath, credential) {
937
938
  `, { mode: 384 });
938
939
  import_node_fs.default.chmodSync(filePath, 384);
939
940
  }
940
- function configureContainerRegistryAuth(credential) {
941
- containerRegistryCredential = credential;
941
+ function configureGitHubAuth(credential) {
942
+ githubCredential = credential;
942
943
  if (!credential) {
943
944
  return;
944
945
  }
@@ -946,25 +947,41 @@ function configureContainerRegistryAuth(credential) {
946
947
  writeRegistryAuthFile(containersAuthPath(), credential);
947
948
  if (credential.missingScopes.length > 0) {
948
949
  process.stderr.write(
949
- `[r5d-worker] GitHub token is missing GHCR scope(s): ${credential.missingScopes.join(", ")}. Sign in with GitHub again if GHCR push/pull fails.
950
+ `[r5d-worker] GitHub token is missing scope(s): ${credential.missingScopes.join(", ")}. Sign in with GitHub again if gh or GHCR access fails.
950
951
  `
951
952
  );
952
953
  } else {
953
- process.stdout.write(`[r5d-worker] configured GHCR auth for ${credential.username}
954
+ process.stdout.write(`[r5d-worker] configured GitHub CLI and GHCR auth for ${credential.username}
954
955
  `);
955
956
  }
956
957
  }
957
958
  function containerRegistryEnv() {
958
- if (!containerRegistryCredential) {
959
+ if (!githubCredential) {
959
960
  return {};
960
961
  }
961
962
  return {
962
- R5D_GHCR_REGISTRY: containerRegistryCredential.registry,
963
- R5D_GHCR_NAMESPACE: containerRegistryCredential.username,
963
+ R5D_GHCR_REGISTRY: githubCredential.registry,
964
+ R5D_GHCR_NAMESPACE: githubCredential.username,
964
965
  R5D_GHCR_AUTH_FILE: containersAuthPath(),
965
966
  REGISTRY_AUTH_FILE: containersAuthPath(),
966
- GHCR_REGISTRY: containerRegistryCredential.registry,
967
- GHCR_NAMESPACE: containerRegistryCredential.username
967
+ GHCR_REGISTRY: githubCredential.registry,
968
+ GHCR_NAMESPACE: githubCredential.username
969
+ };
970
+ }
971
+ function githubCliEnv(token) {
972
+ if (!token) {
973
+ return {};
974
+ }
975
+ return {
976
+ GH_TOKEN: token,
977
+ GH_HOST: "github.com",
978
+ GH_PROMPT_DISABLED: "1"
979
+ };
980
+ }
981
+ function githubProcessEnv() {
982
+ return {
983
+ ...containerRegistryEnv(),
984
+ ...githubCliEnv(githubCredential?.token)
968
985
  };
969
986
  }
970
987
  function checkoutVisibleBranch(input) {
@@ -1910,7 +1927,7 @@ async function executeCommand(input) {
1910
1927
  detached: true,
1911
1928
  env: {
1912
1929
  ...process.env,
1913
- ...containerRegistryEnv(),
1930
+ ...githubProcessEnv(),
1914
1931
  ...input.message.env ?? {},
1915
1932
  ...internalGitProcessEnv(workspace, input.message.env),
1916
1933
  ...artifactProcessEnv,
@@ -2015,7 +2032,7 @@ async function executeStreamingCommand(input) {
2015
2032
  detached: true,
2016
2033
  env: {
2017
2034
  ...process.env,
2018
- ...containerRegistryEnv(),
2035
+ ...githubProcessEnv(),
2019
2036
  ...input.message.env ?? {},
2020
2037
  ...internalGitProcessEnv(workspace, input.message.env),
2021
2038
  ...artifactProcessEnv,
@@ -2346,7 +2363,7 @@ async function openPty(input) {
2346
2363
  cwd: branchPath.branchPath,
2347
2364
  env: {
2348
2365
  ...process.env,
2349
- ...containerRegistryEnv(),
2366
+ ...githubProcessEnv(),
2350
2367
  ...input.message.env ?? {},
2351
2368
  ...planProcessEnv,
2352
2369
  R5D_PROJECT_ID: input.projectId,
@@ -2530,7 +2547,7 @@ async function startWorker(options) {
2530
2547
  return;
2531
2548
  }
2532
2549
  if (message.type === "project_manifest") {
2533
- configureContainerRegistryAuth(message.githubContainerRegistry);
2550
+ configureGitHubAuth(message.githubCredential);
2534
2551
  visibleGitIdentity = message.gitIdentity;
2535
2552
  manifestByProjectId.clear();
2536
2553
  for (const project of message.projects) {
@@ -2920,6 +2937,7 @@ if (isCliEntrypoint()) {
2920
2937
  ensureVisibleGitCheckout,
2921
2938
  findRepositorySyncBlockers,
2922
2939
  findWorkerFiles,
2940
+ githubCliEnv,
2923
2941
  grepWorkerFiles,
2924
2942
  isArtifactEnvPath,
2925
2943
  listWorkerDirectory,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "type": "commonjs"
5
5
  }
package/dist/mjs/main.mjs CHANGED
@@ -23,7 +23,7 @@ const activeProcesses = /* @__PURE__ */ new Map();
23
23
  const cancelledProcessRuns = /* @__PURE__ */ new Set();
24
24
  const activePtys = /* @__PURE__ */ new Map();
25
25
  let currentWorkerSocket = null;
26
- let containerRegistryCredential = null;
26
+ let githubCredential = null;
27
27
  let visibleGitIdentity = null;
28
28
  function defaultConfigPath() {
29
29
  return path.join(os.homedir(), ".config", "r5d", "r5dctl", "config.json");
@@ -879,8 +879,8 @@ function writeRegistryAuthFile(filePath, credential) {
879
879
  const auths = existingAuths;
880
880
  auths[credential.registry] = {
881
881
  username: credential.username,
882
- password: credential.password,
883
- auth: Buffer.from(`${credential.username}:${credential.password}`).toString("base64")
882
+ password: credential.token,
883
+ auth: Buffer.from(`${credential.username}:${credential.token}`).toString("base64")
884
884
  };
885
885
  config.auths = auths;
886
886
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
@@ -888,8 +888,8 @@ function writeRegistryAuthFile(filePath, credential) {
888
888
  `, { mode: 384 });
889
889
  fs.chmodSync(filePath, 384);
890
890
  }
891
- function configureContainerRegistryAuth(credential) {
892
- containerRegistryCredential = credential;
891
+ function configureGitHubAuth(credential) {
892
+ githubCredential = credential;
893
893
  if (!credential) {
894
894
  return;
895
895
  }
@@ -897,25 +897,41 @@ function configureContainerRegistryAuth(credential) {
897
897
  writeRegistryAuthFile(containersAuthPath(), credential);
898
898
  if (credential.missingScopes.length > 0) {
899
899
  process.stderr.write(
900
- `[r5d-worker] GitHub token is missing GHCR scope(s): ${credential.missingScopes.join(", ")}. Sign in with GitHub again if GHCR push/pull fails.
900
+ `[r5d-worker] GitHub token is missing scope(s): ${credential.missingScopes.join(", ")}. Sign in with GitHub again if gh or GHCR access fails.
901
901
  `
902
902
  );
903
903
  } else {
904
- process.stdout.write(`[r5d-worker] configured GHCR auth for ${credential.username}
904
+ process.stdout.write(`[r5d-worker] configured GitHub CLI and GHCR auth for ${credential.username}
905
905
  `);
906
906
  }
907
907
  }
908
908
  function containerRegistryEnv() {
909
- if (!containerRegistryCredential) {
909
+ if (!githubCredential) {
910
910
  return {};
911
911
  }
912
912
  return {
913
- R5D_GHCR_REGISTRY: containerRegistryCredential.registry,
914
- R5D_GHCR_NAMESPACE: containerRegistryCredential.username,
913
+ R5D_GHCR_REGISTRY: githubCredential.registry,
914
+ R5D_GHCR_NAMESPACE: githubCredential.username,
915
915
  R5D_GHCR_AUTH_FILE: containersAuthPath(),
916
916
  REGISTRY_AUTH_FILE: containersAuthPath(),
917
- GHCR_REGISTRY: containerRegistryCredential.registry,
918
- GHCR_NAMESPACE: containerRegistryCredential.username
917
+ GHCR_REGISTRY: githubCredential.registry,
918
+ GHCR_NAMESPACE: githubCredential.username
919
+ };
920
+ }
921
+ function githubCliEnv(token) {
922
+ if (!token) {
923
+ return {};
924
+ }
925
+ return {
926
+ GH_TOKEN: token,
927
+ GH_HOST: "github.com",
928
+ GH_PROMPT_DISABLED: "1"
929
+ };
930
+ }
931
+ function githubProcessEnv() {
932
+ return {
933
+ ...containerRegistryEnv(),
934
+ ...githubCliEnv(githubCredential?.token)
919
935
  };
920
936
  }
921
937
  function checkoutVisibleBranch(input) {
@@ -1861,7 +1877,7 @@ async function executeCommand(input) {
1861
1877
  detached: true,
1862
1878
  env: {
1863
1879
  ...process.env,
1864
- ...containerRegistryEnv(),
1880
+ ...githubProcessEnv(),
1865
1881
  ...input.message.env ?? {},
1866
1882
  ...internalGitProcessEnv(workspace, input.message.env),
1867
1883
  ...artifactProcessEnv,
@@ -1966,7 +1982,7 @@ async function executeStreamingCommand(input) {
1966
1982
  detached: true,
1967
1983
  env: {
1968
1984
  ...process.env,
1969
- ...containerRegistryEnv(),
1985
+ ...githubProcessEnv(),
1970
1986
  ...input.message.env ?? {},
1971
1987
  ...internalGitProcessEnv(workspace, input.message.env),
1972
1988
  ...artifactProcessEnv,
@@ -2297,7 +2313,7 @@ async function openPty(input) {
2297
2313
  cwd: branchPath.branchPath,
2298
2314
  env: {
2299
2315
  ...process.env,
2300
- ...containerRegistryEnv(),
2316
+ ...githubProcessEnv(),
2301
2317
  ...input.message.env ?? {},
2302
2318
  ...planProcessEnv,
2303
2319
  R5D_PROJECT_ID: input.projectId,
@@ -2481,7 +2497,7 @@ async function startWorker(options) {
2481
2497
  return;
2482
2498
  }
2483
2499
  if (message.type === "project_manifest") {
2484
- configureContainerRegistryAuth(message.githubContainerRegistry);
2500
+ configureGitHubAuth(message.githubCredential);
2485
2501
  visibleGitIdentity = message.gitIdentity;
2486
2502
  manifestByProjectId.clear();
2487
2503
  for (const project of message.projects) {
@@ -2870,6 +2886,7 @@ export {
2870
2886
  ensureVisibleGitCheckout,
2871
2887
  findRepositorySyncBlockers,
2872
2888
  findWorkerFiles,
2889
+ githubCliEnv,
2873
2890
  grepWorkerFiles,
2874
2891
  isArtifactEnvPath,
2875
2892
  listWorkerDirectory,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "type": "module"
5
5
  }
@@ -119,6 +119,7 @@ export declare function resolveWorkerFilePath(branchPath: string, inputPath: str
119
119
  export declare function resolveProjectFilePath(branchPath: string, inputPath: string): Extract<ResolvedWorkerFilePath, {
120
120
  scope: "project";
121
121
  }>;
122
+ export declare function githubCliEnv(token: string | null | undefined): Record<string, string>;
122
123
  export declare function ensureVisibleGitCheckout(input: {
123
124
  projectRoot: string;
124
125
  branchName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/main.cjs",
6
6
  "module": "./dist/mjs/main.mjs",