minimal-forge-work-pack-sync 0.1.7 → 0.1.9
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/index.js +47 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7415,6 +7415,7 @@ function resolveOpenCodeDir(home, platform, env, exists, pathApi) {
|
|
|
7415
7415
|
|
|
7416
7416
|
// packages/cli/src/report.ts
|
|
7417
7417
|
import os2 from "node:os";
|
|
7418
|
+
var AGENT_VERSION = "0.1.0";
|
|
7418
7419
|
async function reportFailure(credentials, kind, error) {
|
|
7419
7420
|
try {
|
|
7420
7421
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -7424,7 +7425,7 @@ async function reportFailure(credentials, kind, error) {
|
|
|
7424
7425
|
authorization: `Bearer ${credentials.forgeApiKey}`,
|
|
7425
7426
|
"content-type": "application/json",
|
|
7426
7427
|
"x-forge-hostname": os2.hostname(),
|
|
7427
|
-
"x-forge-agent-version":
|
|
7428
|
+
"x-forge-agent-version": AGENT_VERSION
|
|
7428
7429
|
},
|
|
7429
7430
|
body: JSON.stringify({
|
|
7430
7431
|
kind,
|
|
@@ -7437,6 +7438,23 @@ async function reportFailure(credentials, kind, error) {
|
|
|
7437
7438
|
console.error("[Forge] Failed to report failure to Forge server:", error2 instanceof Error ? error2.message : String(error2));
|
|
7438
7439
|
}
|
|
7439
7440
|
}
|
|
7441
|
+
async function reportWorkPackObservations(credentials, kind, workPacks) {
|
|
7442
|
+
try {
|
|
7443
|
+
await fetch(`${credentials.forgeBaseUrl.replace(/\/$/, "")}/sync/report`, {
|
|
7444
|
+
method: "POST",
|
|
7445
|
+
headers: {
|
|
7446
|
+
authorization: `Bearer ${credentials.forgeApiKey}`,
|
|
7447
|
+
"content-type": "application/json",
|
|
7448
|
+
"x-forge-hostname": os2.hostname(),
|
|
7449
|
+
"x-forge-agent-version": AGENT_VERSION
|
|
7450
|
+
},
|
|
7451
|
+
body: JSON.stringify({ kind, ok: true, workPacks }),
|
|
7452
|
+
signal: AbortSignal.timeout(3e3)
|
|
7453
|
+
});
|
|
7454
|
+
} catch (error) {
|
|
7455
|
+
console.error("[Forge] Failed to report Work Pack state to Forge server:", error instanceof Error ? error.message : String(error));
|
|
7456
|
+
}
|
|
7457
|
+
}
|
|
7440
7458
|
|
|
7441
7459
|
// packages/cli/src/sync.ts
|
|
7442
7460
|
import { createHash } from "node:crypto";
|
|
@@ -10582,7 +10600,7 @@ var DEFAULT_DEBUG_TRACE_LIMITS = {
|
|
|
10582
10600
|
};
|
|
10583
10601
|
|
|
10584
10602
|
// packages/shared/src/contracts/settings.ts
|
|
10585
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
10603
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.9";
|
|
10586
10604
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
10587
10605
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
10588
10606
|
|
|
@@ -10827,7 +10845,29 @@ async function applyWorkPackManifest(paths, credentials, manifest, options) {
|
|
|
10827
10845
|
const installed = workPacks.outcomes.filter((outcome) => outcome.status === "installed").map((outcome) => `${outcome.slug}@${outcome.version}`);
|
|
10828
10846
|
const removed = workPacks.outcomes.filter((outcome) => outcome.status === "removed").map((outcome) => outcome.slug);
|
|
10829
10847
|
const removedManagedPaths = [...new Set(workPacks.outcomes.flatMap((outcome) => outcome.removedManagedPaths ?? []))].sort();
|
|
10830
|
-
|
|
10848
|
+
const workPackObservations = await collectWorkPackObservations(paths, workPacks);
|
|
10849
|
+
return { installed, removed, removedManagedPaths, workPacks, workPackObservations };
|
|
10850
|
+
}
|
|
10851
|
+
async function collectWorkPackObservations(paths, reconciliation) {
|
|
10852
|
+
const installedVersions = /* @__PURE__ */ new Map();
|
|
10853
|
+
for (const slug of await managedWorkPackSlugs(paths.skillsDir)) {
|
|
10854
|
+
const version = (await readFile(path2.join(paths.skillsDir, slug, ".forge-version"), "utf8")).trim();
|
|
10855
|
+
if (version) installedVersions.set(slug, version);
|
|
10856
|
+
}
|
|
10857
|
+
const observations = new Map(
|
|
10858
|
+
[...installedVersions].map(([slug, version]) => [slug, { slug, state: "installed", version }])
|
|
10859
|
+
);
|
|
10860
|
+
for (const outcome of reconciliation.outcomes) {
|
|
10861
|
+
if (outcome.status !== "failed" && outcome.status !== "recovery-uncertain") continue;
|
|
10862
|
+
observations.set(outcome.slug, {
|
|
10863
|
+
slug: outcome.slug,
|
|
10864
|
+
state: "failed",
|
|
10865
|
+
...outcome.version ? { version: outcome.version } : {},
|
|
10866
|
+
...installedVersions.get(outcome.slug) ? { installedVersion: installedVersions.get(outcome.slug) } : {},
|
|
10867
|
+
errorCode: outcome.code ?? outcome.status
|
|
10868
|
+
});
|
|
10869
|
+
}
|
|
10870
|
+
return [...observations.values()].sort((a, b2) => a.slug.localeCompare(b2.slug));
|
|
10831
10871
|
}
|
|
10832
10872
|
async function operateWorkPack(paths, credentials, skillBySlug, approvedModelIds, cleanupPendingSlugs, operation, options) {
|
|
10833
10873
|
const target = path2.join(paths.skillsDir, operation.pack.slug);
|
|
@@ -11490,7 +11530,7 @@ async function writeTextAtomic(filePath, content) {
|
|
|
11490
11530
|
}
|
|
11491
11531
|
|
|
11492
11532
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
11493
|
-
var PLUGIN_VERSION = "0.1.
|
|
11533
|
+
var PLUGIN_VERSION = "0.1.9";
|
|
11494
11534
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
11495
11535
|
var activeSync = /* @__PURE__ */ new Map();
|
|
11496
11536
|
var ForgeWorkPackSyncServer = async (_input, options) => {
|
|
@@ -11515,6 +11555,7 @@ async function synchronizeAtStartup(forgeBaseUrl) {
|
|
|
11515
11555
|
credentials = await readWellKnownForgeCredentials(paths.opencodeAuthPath, forgeBaseUrl);
|
|
11516
11556
|
const manifest = await fetchManifest(credentials);
|
|
11517
11557
|
const result = await applyWorkPackManifest(paths, credentials, manifest, {});
|
|
11558
|
+
await reportWorkPackObservations(credentials, "sync", result.workPackObservations);
|
|
11518
11559
|
const failures = result.workPacks.outcomes.filter(
|
|
11519
11560
|
(outcome) => outcome.status === "failed" || outcome.status === "recovery-uncertain"
|
|
11520
11561
|
);
|
|
@@ -11543,7 +11584,8 @@ async function synchronizeAtStartup(forgeBaseUrl) {
|
|
|
11543
11584
|
message
|
|
11544
11585
|
}).catch(() => void 0);
|
|
11545
11586
|
if (credentials) await reportFailure(credentials, "sync", new Error(message));
|
|
11546
|
-
|
|
11587
|
+
const after = await managedProjectionNames(paths).catch(() => before);
|
|
11588
|
+
return { paths, before, after };
|
|
11547
11589
|
}
|
|
11548
11590
|
}
|
|
11549
11591
|
function resolveStartupPaths() {
|