@osfactory/har 0.33.0 → 0.33.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 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -76163,8 +76163,7 @@ async function syncReposWithControl(options) {
76163
76163
  async function syncAllKnownReposWithControl(options) {
76164
76164
  if (!isControlEnabled()) return { synced: 0, failed: 0 };
76165
76165
  const apiUrl = options?.apiUrl ?? getControlApiUrl();
76166
- const portal = getPortalTarget();
76167
- if (!await isControlApiReachable(portal ? portal.url : apiUrl)) {
76166
+ if (!await isControlApiReachable(apiUrl)) {
76168
76167
  return { synced: 0, failed: 0 };
76169
76168
  }
76170
76169
  const repoPaths = await discoverHarRepos({ apiUrl, cwd: options?.cwd });
@@ -76199,6 +76198,40 @@ async function registerRepoWithControl(options) {
76199
76198
  }
76200
76199
  return await response.json();
76201
76200
  }
76201
+ async function syncRepoWithLocalControl(options) {
76202
+ const apiUrl = options.apiUrl ?? getControlApiUrl();
76203
+ const { repoPath, dryRun } = options;
76204
+ const registerResult = await registerRepoWithControl({ ...options, repoPath });
76205
+ const repoId = registerResult?.id;
76206
+ if (!repoId && !dryRun) {
76207
+ const listResponse = await fetch(`${apiUrl}/api/repos`);
76208
+ if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
76209
+ const repos = await listResponse.json();
76210
+ const existing = repos.find((r2) => path43.resolve(r2.path) === repoPath);
76211
+ if (!existing) {
76212
+ return;
76213
+ }
76214
+ await syncRepoRunsAndSlots(apiUrl, existing.id, repoPath, dryRun);
76215
+ return;
76216
+ }
76217
+ if (repoId) {
76218
+ await syncRepoRunsAndSlots(apiUrl, repoId, repoPath, dryRun);
76219
+ }
76220
+ }
76221
+ async function syncRepoWithPortal(options, controlApiUrl) {
76222
+ const portal = getPortalTarget();
76223
+ if (!portal) return;
76224
+ const { repoPath, dryRun, full } = options;
76225
+ const since = full ? null : readPortalWatermark(repoPath, portal.url);
76226
+ const { syncBody, events, maxSyncedAt } = await buildPortalPayload(repoPath, controlApiUrl, since);
76227
+ await postPortal(portal, "/api/sync", syncBody, dryRun);
76228
+ if (events.length > 0) {
76229
+ await postPortal(portal, "/api/otel", { path: repoPath, events, spans: [] }, dryRun);
76230
+ }
76231
+ if (!dryRun && maxSyncedAt) {
76232
+ writePortalWatermark(repoPath, portal.url, maxSyncedAt);
76233
+ }
76234
+ }
76202
76235
  async function syncRepoWithControl(options) {
76203
76236
  const repoPath = canonicalizeControlRepoPath(options.repoPath);
76204
76237
  const apiUrl = options.apiUrl ?? getControlApiUrl();
@@ -76231,40 +76264,8 @@ async function syncRepoWithControl(options) {
76231
76264
  }
76232
76265
  return;
76233
76266
  }
76234
- const portal = getPortalTarget();
76235
- if (portal) {
76236
- const since = options.full ? null : readPortalWatermark(repoPath, portal.url);
76237
- const { syncBody, events, maxSyncedAt } = await buildPortalPayload(repoPath, apiUrl, since);
76238
- await postPortal(portal, "/api/sync", syncBody, options.dryRun);
76239
- if (events.length > 0) {
76240
- await postPortal(
76241
- portal,
76242
- "/api/otel",
76243
- { path: repoPath, events, spans: [] },
76244
- options.dryRun
76245
- );
76246
- }
76247
- if (!options.dryRun && maxSyncedAt) {
76248
- writePortalWatermark(repoPath, portal.url, maxSyncedAt);
76249
- }
76250
- return;
76251
- }
76252
- const registerResult = await registerRepoWithControl({ ...options, repoPath });
76253
- const repoId = registerResult?.id;
76254
- if (!repoId && !options.dryRun) {
76255
- const listResponse = await fetch(`${apiUrl}/api/repos`);
76256
- if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
76257
- const repos = await listResponse.json();
76258
- const existing = repos.find((r2) => path43.resolve(r2.path) === repoPath);
76259
- if (!existing) {
76260
- return;
76261
- }
76262
- await syncRepoRunsAndSlots(apiUrl, existing.id, repoPath, options.dryRun);
76263
- return;
76264
- }
76265
- if (repoId) {
76266
- await syncRepoRunsAndSlots(apiUrl, repoId, repoPath, options.dryRun);
76267
- }
76267
+ await syncRepoWithLocalControl({ ...options, repoPath, apiUrl });
76268
+ await syncRepoWithPortal({ ...options, repoPath }, apiUrl);
76268
76269
  }
76269
76270
  async function syncRepoRunsAndSlots(apiUrl, repoId, repoPath, dryRun) {
76270
76271
  const runs = listRuns(repoPath);
@@ -76365,11 +76366,10 @@ async function syncRepoWithControlAsync(repoPath) {
76365
76366
  if (process.env.HAR_CONTROL_DISABLED === "true" || process.env.NODE_ENV === "test") return;
76366
76367
  const verbose = process.env.HAR_CONTROL_VERBOSE === "true";
76367
76368
  try {
76368
- const portal = getPortalTarget();
76369
- const healthUrl = portal ? portal.url : getControlApiUrl();
76370
- if (!await isControlApiReachable(healthUrl)) {
76369
+ const apiUrl = getControlApiUrl();
76370
+ if (!await isControlApiReachable(apiUrl)) {
76371
76371
  if (verbose) {
76372
- process.stderr.write(`[har control] sync skipped: not reachable at ${healthUrl}
76372
+ process.stderr.write(`[har control] sync skipped: not reachable at ${apiUrl}
76373
76373
  `);
76374
76374
  }
76375
76375
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfactory/har",
3
- "version": "0.33.0",
3
+ "version": "0.33.1",
4
4
  "description": "LLM-powered CLI for reproducible agent development environments",
5
5
  "keywords": [
6
6
  "har",