@ricsam/r5d-worker 0.0.34 → 0.0.36

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/dist/cjs/main.cjs CHANGED
@@ -43,7 +43,6 @@ __export(main_exports, {
43
43
  resolveHostShell: () => resolveHostShell,
44
44
  resolveProjectFilePath: () => resolveProjectFilePath,
45
45
  resolveWorkerFilePath: () => resolveWorkerFilePath,
46
- selectManifestSyncTargets: () => selectManifestSyncTargets,
47
46
  syncManifestProjectsFromInternal: () => syncManifestProjectsFromInternal,
48
47
  syncProjectPlans: () => syncProjectPlans,
49
48
  syncSessionArtifacts: () => syncSessionArtifacts
@@ -1163,28 +1162,11 @@ function findRepositorySyncBlockers(input) {
1163
1162
  }
1164
1163
  return blockedBy;
1165
1164
  }
1166
- function selectManifestSyncTargets(input) {
1167
- if (!input.requestedTargets) {
1168
- return input.manifests.flatMap((manifest) => {
1169
- const branches = manifest.branches.length > 0 ? manifest.branches : [manifest.defaultBranch || "main"];
1170
- return [...new Set(branches)].map((branchName) => ({ manifest, branchName }));
1171
- });
1172
- }
1173
- const manifestsByProjectId = new Map(input.manifests.map((manifest) => [manifest.projectId, manifest]));
1174
- const selected = /* @__PURE__ */ new Map();
1175
- for (const target of input.requestedTargets) {
1176
- const manifest = manifestsByProjectId.get(target.projectId);
1177
- if (!manifest) {
1178
- continue;
1179
- }
1180
- selected.set(`${target.projectId}\0${target.branchName}`, { manifest, branchName: target.branchName });
1181
- }
1182
- return [...selected.values()];
1183
- }
1184
1165
  async function syncManifestProjectsFromInternal(input) {
1185
- const targets = selectManifestSyncTargets({
1186
- manifests: input.manifests,
1187
- requestedTargets: input.requestedTargets
1166
+ const requestedProjectIds = input.projectIds ? new Set(input.projectIds) : null;
1167
+ const targets = input.manifests.filter((manifest) => !requestedProjectIds || requestedProjectIds.has(manifest.projectId)).flatMap((manifest) => {
1168
+ const branches = manifest.branches.length > 0 ? manifest.branches : [manifest.defaultBranch || "main"];
1169
+ return [...new Set(branches)].map((branchName) => ({ manifest, branchName }));
1188
1170
  });
1189
1171
  const blockedBy = findRepositorySyncBlockers({
1190
1172
  targets: targets.map(({ manifest, branchName }) => ({
@@ -1203,12 +1185,11 @@ async function syncManifestProjectsFromInternal(input) {
1203
1185
  branchName: active.branchName
1204
1186
  }))
1205
1187
  });
1206
- const blockedTargetKeys = new Set(blockedBy.map((blocker) => `${blocker.projectId}\0${blocker.branchName}`));
1188
+ if (blockedBy.length > 0) {
1189
+ return { status: "blocked", results: [], blockedBy };
1190
+ }
1207
1191
  const results = [];
1208
1192
  for (const { manifest, branchName } of targets) {
1209
- if (blockedTargetKeys.has(`${manifest.projectId}\0${branchName}`)) {
1210
- continue;
1211
- }
1212
1193
  try {
1213
1194
  const commitHash = await forceSyncManifestBranchFromInternal({
1214
1195
  projectId: manifest.projectId,
@@ -1236,11 +1217,10 @@ async function syncManifestProjectsFromInternal(input) {
1236
1217
  });
1237
1218
  }
1238
1219
  }
1239
- const hasFailures = results.some((result) => result.status === "failed");
1240
1220
  return {
1241
- status: blockedBy.length > 0 && results.length === 0 ? "blocked" : blockedBy.length > 0 || hasFailures ? "partial" : "completed",
1221
+ status: results.some((result) => result.status === "failed") ? "partial" : "completed",
1242
1222
  results,
1243
- blockedBy
1223
+ blockedBy: []
1244
1224
  };
1245
1225
  }
1246
1226
  function resolveCommandCwd(branchPath, cwd) {
@@ -1959,9 +1939,12 @@ async function executeCommand(input) {
1959
1939
  projectId: input.projectId,
1960
1940
  sessionId: input.message.sessionId ?? "",
1961
1941
  branchName: input.message.branchName,
1942
+ mode: "foreground",
1943
+ pid: subprocess.pid,
1944
+ processGroupId: process.platform === "win32" ? void 0 : subprocess.pid,
1962
1945
  argv: input.message.argv,
1963
1946
  command: input.message.argv.join(" "),
1964
- cwd: input.message.cwd,
1947
+ cwd,
1965
1948
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
1966
1949
  });
1967
1950
  if (input.message.timeoutMs) {
@@ -2064,17 +2047,23 @@ async function executeStreamingCommand(input) {
2064
2047
  projectId: input.projectId,
2065
2048
  sessionId: input.message.sessionId,
2066
2049
  branchName: input.message.branchName,
2050
+ mode: input.message.mode,
2051
+ pid: subprocess.pid,
2052
+ processGroupId: process.platform === "win32" ? void 0 : subprocess.pid,
2067
2053
  credentialId: input.message.credentialId,
2068
2054
  argv: input.message.argv,
2069
2055
  command: input.message.command,
2070
- cwd: input.message.cwd,
2056
+ cwd,
2071
2057
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
2072
2058
  });
2073
2059
  started = true;
2074
2060
  sendWorkerMessage(input.ws, {
2075
2061
  type: "exec_started",
2076
2062
  requestId: input.message.requestId,
2077
- runId: input.message.runId
2063
+ runId: input.message.runId,
2064
+ cwd,
2065
+ pid: subprocess.pid,
2066
+ ...process.platform === "win32" ? {} : { processGroupId: subprocess.pid }
2078
2067
  });
2079
2068
  if (input.message.timeoutMs) {
2080
2069
  timeout = setTimeout(() => {
@@ -2153,6 +2142,11 @@ function buildActiveProcessReports() {
2153
2142
  projectId: active.projectId,
2154
2143
  sessionId: active.sessionId,
2155
2144
  branchName: active.branchName,
2145
+ platform: process.platform,
2146
+ arch: process.arch,
2147
+ mode: active.mode,
2148
+ ...active.pid !== void 0 ? { pid: active.pid } : {},
2149
+ ...active.processGroupId !== void 0 ? { processGroupId: active.processGroupId } : {},
2156
2150
  ...active.credentialId ? { credentialId: active.credentialId } : {},
2157
2151
  argv: active.argv,
2158
2152
  command: active.command,
@@ -2600,7 +2594,7 @@ async function startWorker(options) {
2600
2594
  projectsRoot,
2601
2595
  syncRoot,
2602
2596
  manifests: [...manifestByProjectId.values()],
2603
- requestedTargets: message.targets
2597
+ projectIds: message.projectIds
2604
2598
  });
2605
2599
  for (const result of syncResult.results) {
2606
2600
  if (result.status !== "synced") continue;
@@ -2968,7 +2962,6 @@ if (isCliEntrypoint()) {
2968
2962
  resolveHostShell,
2969
2963
  resolveProjectFilePath,
2970
2964
  resolveWorkerFilePath,
2971
- selectManifestSyncTargets,
2972
2965
  syncManifestProjectsFromInternal,
2973
2966
  syncProjectPlans,
2974
2967
  syncSessionArtifacts
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "commonjs"
5
5
  }
package/dist/mjs/main.mjs CHANGED
@@ -1112,28 +1112,11 @@ function findRepositorySyncBlockers(input) {
1112
1112
  }
1113
1113
  return blockedBy;
1114
1114
  }
1115
- function selectManifestSyncTargets(input) {
1116
- if (!input.requestedTargets) {
1117
- return input.manifests.flatMap((manifest) => {
1118
- const branches = manifest.branches.length > 0 ? manifest.branches : [manifest.defaultBranch || "main"];
1119
- return [...new Set(branches)].map((branchName) => ({ manifest, branchName }));
1120
- });
1121
- }
1122
- const manifestsByProjectId = new Map(input.manifests.map((manifest) => [manifest.projectId, manifest]));
1123
- const selected = /* @__PURE__ */ new Map();
1124
- for (const target of input.requestedTargets) {
1125
- const manifest = manifestsByProjectId.get(target.projectId);
1126
- if (!manifest) {
1127
- continue;
1128
- }
1129
- selected.set(`${target.projectId}\0${target.branchName}`, { manifest, branchName: target.branchName });
1130
- }
1131
- return [...selected.values()];
1132
- }
1133
1115
  async function syncManifestProjectsFromInternal(input) {
1134
- const targets = selectManifestSyncTargets({
1135
- manifests: input.manifests,
1136
- requestedTargets: input.requestedTargets
1116
+ const requestedProjectIds = input.projectIds ? new Set(input.projectIds) : null;
1117
+ const targets = input.manifests.filter((manifest) => !requestedProjectIds || requestedProjectIds.has(manifest.projectId)).flatMap((manifest) => {
1118
+ const branches = manifest.branches.length > 0 ? manifest.branches : [manifest.defaultBranch || "main"];
1119
+ return [...new Set(branches)].map((branchName) => ({ manifest, branchName }));
1137
1120
  });
1138
1121
  const blockedBy = findRepositorySyncBlockers({
1139
1122
  targets: targets.map(({ manifest, branchName }) => ({
@@ -1152,12 +1135,11 @@ async function syncManifestProjectsFromInternal(input) {
1152
1135
  branchName: active.branchName
1153
1136
  }))
1154
1137
  });
1155
- const blockedTargetKeys = new Set(blockedBy.map((blocker) => `${blocker.projectId}\0${blocker.branchName}`));
1138
+ if (blockedBy.length > 0) {
1139
+ return { status: "blocked", results: [], blockedBy };
1140
+ }
1156
1141
  const results = [];
1157
1142
  for (const { manifest, branchName } of targets) {
1158
- if (blockedTargetKeys.has(`${manifest.projectId}\0${branchName}`)) {
1159
- continue;
1160
- }
1161
1143
  try {
1162
1144
  const commitHash = await forceSyncManifestBranchFromInternal({
1163
1145
  projectId: manifest.projectId,
@@ -1185,11 +1167,10 @@ async function syncManifestProjectsFromInternal(input) {
1185
1167
  });
1186
1168
  }
1187
1169
  }
1188
- const hasFailures = results.some((result) => result.status === "failed");
1189
1170
  return {
1190
- status: blockedBy.length > 0 && results.length === 0 ? "blocked" : blockedBy.length > 0 || hasFailures ? "partial" : "completed",
1171
+ status: results.some((result) => result.status === "failed") ? "partial" : "completed",
1191
1172
  results,
1192
- blockedBy
1173
+ blockedBy: []
1193
1174
  };
1194
1175
  }
1195
1176
  function resolveCommandCwd(branchPath, cwd) {
@@ -1908,9 +1889,12 @@ async function executeCommand(input) {
1908
1889
  projectId: input.projectId,
1909
1890
  sessionId: input.message.sessionId ?? "",
1910
1891
  branchName: input.message.branchName,
1892
+ mode: "foreground",
1893
+ pid: subprocess.pid,
1894
+ processGroupId: process.platform === "win32" ? void 0 : subprocess.pid,
1911
1895
  argv: input.message.argv,
1912
1896
  command: input.message.argv.join(" "),
1913
- cwd: input.message.cwd,
1897
+ cwd,
1914
1898
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
1915
1899
  });
1916
1900
  if (input.message.timeoutMs) {
@@ -2013,17 +1997,23 @@ async function executeStreamingCommand(input) {
2013
1997
  projectId: input.projectId,
2014
1998
  sessionId: input.message.sessionId,
2015
1999
  branchName: input.message.branchName,
2000
+ mode: input.message.mode,
2001
+ pid: subprocess.pid,
2002
+ processGroupId: process.platform === "win32" ? void 0 : subprocess.pid,
2016
2003
  credentialId: input.message.credentialId,
2017
2004
  argv: input.message.argv,
2018
2005
  command: input.message.command,
2019
- cwd: input.message.cwd,
2006
+ cwd,
2020
2007
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
2021
2008
  });
2022
2009
  started = true;
2023
2010
  sendWorkerMessage(input.ws, {
2024
2011
  type: "exec_started",
2025
2012
  requestId: input.message.requestId,
2026
- runId: input.message.runId
2013
+ runId: input.message.runId,
2014
+ cwd,
2015
+ pid: subprocess.pid,
2016
+ ...process.platform === "win32" ? {} : { processGroupId: subprocess.pid }
2027
2017
  });
2028
2018
  if (input.message.timeoutMs) {
2029
2019
  timeout = setTimeout(() => {
@@ -2102,6 +2092,11 @@ function buildActiveProcessReports() {
2102
2092
  projectId: active.projectId,
2103
2093
  sessionId: active.sessionId,
2104
2094
  branchName: active.branchName,
2095
+ platform: process.platform,
2096
+ arch: process.arch,
2097
+ mode: active.mode,
2098
+ ...active.pid !== void 0 ? { pid: active.pid } : {},
2099
+ ...active.processGroupId !== void 0 ? { processGroupId: active.processGroupId } : {},
2105
2100
  ...active.credentialId ? { credentialId: active.credentialId } : {},
2106
2101
  argv: active.argv,
2107
2102
  command: active.command,
@@ -2549,7 +2544,7 @@ async function startWorker(options) {
2549
2544
  projectsRoot,
2550
2545
  syncRoot,
2551
2546
  manifests: [...manifestByProjectId.values()],
2552
- requestedTargets: message.targets
2547
+ projectIds: message.projectIds
2553
2548
  });
2554
2549
  for (const result of syncResult.results) {
2555
2550
  if (result.status !== "synced") continue;
@@ -2916,7 +2911,6 @@ export {
2916
2911
  resolveHostShell,
2917
2912
  resolveProjectFilePath,
2918
2913
  resolveWorkerFilePath,
2919
- selectManifestSyncTargets,
2920
2914
  syncManifestProjectsFromInternal,
2921
2915
  syncProjectPlans,
2922
2916
  syncSessionArtifacts
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "module"
5
5
  }
@@ -26,10 +26,6 @@ type WorkerRepositorySyncTarget = {
26
26
  projectPath: string;
27
27
  branchName: string;
28
28
  };
29
- type WorkerRepositorySyncSelector = {
30
- projectId: string;
31
- branchName: string;
32
- };
33
29
  type WorkerRepositorySyncResult = {
34
30
  status: "completed" | "partial" | "blocked";
35
31
  results: Array<WorkerRepositorySyncTarget & ({
@@ -146,20 +142,13 @@ export declare function findRepositorySyncBlockers(input: {
146
142
  branchName: string;
147
143
  }>;
148
144
  }): WorkerRepositorySyncResult["blockedBy"];
149
- export declare function selectManifestSyncTargets(input: {
150
- manifests: WorkerProjectManifestEntry[];
151
- requestedTargets?: WorkerRepositorySyncSelector[];
152
- }): Array<{
153
- manifest: WorkerProjectManifestEntry;
154
- branchName: string;
155
- }>;
156
145
  export declare function syncManifestProjectsFromInternal(input: {
157
146
  baseUrl: string;
158
147
  token: string;
159
148
  projectsRoot: string;
160
149
  syncRoot: string;
161
150
  manifests: WorkerProjectManifestEntry[];
162
- requestedTargets?: WorkerRepositorySyncSelector[];
151
+ projectIds?: string[];
163
152
  }): Promise<WorkerRepositorySyncResult>;
164
153
  export declare function readWorkerTextFile(branchPath: string, filePath: string, offset?: number, limit?: number): WorkerReadFileResult;
165
154
  export declare function grepWorkerFiles(branchPath: string, input: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/main.cjs",
6
6
  "module": "./dist/mjs/main.mjs",