minimal-forge-work-pack-sync 0.1.20 → 0.1.22

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 +33 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7548,7 +7548,7 @@ var DEFAULT_DEBUG_TRACE_LIMITS = {
7548
7548
  };
7549
7549
 
7550
7550
  // packages/shared/src/contracts/settings.ts
7551
- var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.20";
7551
+ var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.22";
7552
7552
  var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
7553
7553
  var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
7554
7554
  var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
@@ -7556,6 +7556,9 @@ var FIRECRAWL_KEYLESS_PERMISSION = `${FIRECRAWL_KEYLESS_MCP_NAME}_*`;
7556
7556
 
7557
7557
  // packages/shared/src/workPackBaseline.ts
7558
7558
  function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
7559
+ return normalizeExtensionModel(pathLabel, content, slug, (modelId) => approvedModelIds.has(modelId));
7560
+ }
7561
+ function normalizeExtensionModel(pathLabel, content, slug, acceptsModel) {
7559
7562
  const match = /^---\n([\s\S]+?)\n---/.exec(content);
7560
7563
  const frontmatter = match?.[1];
7561
7564
  if (!match || frontmatter === void 0) return content;
@@ -7568,7 +7571,7 @@ function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug)
7568
7571
  const separator = rawModel.indexOf("/");
7569
7572
  const provider = separator > 0 ? rawModel.slice(0, separator) : "";
7570
7573
  const modelId = separator > 0 ? rawModel.slice(separator + 1) : "";
7571
- if (provider !== "forge" && provider !== "openrouter" || !approvedModelIds.has(modelId)) {
7574
+ if (provider !== "forge" && provider !== "openrouter" || !acceptsModel(modelId)) {
7572
7575
  throw new Error(
7573
7576
  `A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} usa um modelo que n\xE3o est\xE1 aprovado no Forge`
7574
7577
  );
@@ -7630,31 +7633,45 @@ var UNKNOWN_RUNTIME = {
7630
7633
  openwork: { status: "unknown" }
7631
7634
  };
7632
7635
  async function observeRuntime(input) {
7636
+ const engine = input?.serverUrl;
7637
+ const engineHeaders = {};
7638
+ if (process.env.OPENCODE_SERVER_PASSWORD) {
7639
+ engineHeaders.authorization = `Basic ${Buffer.from(`${process.env.OPENCODE_SERVER_USERNAME || "opencode"}:${process.env.OPENCODE_SERVER_PASSWORD}`).toString("base64")}`;
7640
+ }
7641
+ let server;
7642
+ const token = process.env.OPENWORK_SERVER_TOKEN;
7643
+ if (process.env.OPENWORK_SERVER_URL && token) {
7644
+ try {
7645
+ server = new URL(process.env.OPENWORK_SERVER_URL);
7646
+ } catch {
7647
+ }
7648
+ }
7649
+ const [opencode, openwork] = await Promise.all([
7650
+ probeHealth(engine, "/global/health", engineHeaders, "healthy", "engine-health"),
7651
+ probeHealth(server, "/health", token ? { authorization: `Bearer ${token}` } : {}, "ok", "server-health")
7652
+ ]);
7653
+ return { opencode, openwork };
7654
+ }
7655
+ async function probeHealth(url2, route, headers, healthyField, source) {
7656
+ if (!(url2 instanceof URL) || !["http:", "https:"].includes(url2.protocol) || !["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname) || url2.username || url2.password || url2.search || url2.hash) return { status: "unknown" };
7633
7657
  let timer;
7634
7658
  const controller = new AbortController();
7635
7659
  try {
7636
- const url2 = input?.serverUrl;
7637
- if (!(url2 instanceof URL) || !["http:", "https:"].includes(url2.protocol) || !["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname) || url2.username || url2.password) return structuredClone(UNKNOWN_RUNTIME);
7638
- const endpoint = new URL("/global/health", url2);
7639
- const headers = {};
7640
- if (process.env.OPENCODE_SERVER_PASSWORD) {
7641
- headers.authorization = `Basic ${Buffer.from(`${process.env.OPENCODE_SERVER_USERNAME || "opencode"}:${process.env.OPENCODE_SERVER_PASSWORD}`).toString("base64")}`;
7642
- }
7643
7660
  const probe = async () => {
7644
- const response = await fetch(endpoint, { headers, signal: controller.signal, redirect: "error" });
7645
- if (!response.ok) return structuredClone(UNKNOWN_RUNTIME);
7661
+ const response = await fetch(new URL(route, url2), { headers, signal: controller.signal, redirect: "error" });
7662
+ if (!response.ok) return { status: "unknown" };
7646
7663
  const body = await response.json();
7647
- const version2 = runtimeVersion(body.version);
7648
- return { openwork: { status: "unknown" }, opencode: body.healthy === true && version2 ? { status: "known", version: version2, source: "engine-health" } : { status: "unknown" } };
7664
+ const version2 = runtimeVersion(body?.version);
7665
+ return body?.[healthyField] === true && version2 ? { status: "known", version: version2, source } : { status: "unknown" };
7649
7666
  };
7650
7667
  return await Promise.race([probe(), new Promise((resolve) => {
7651
7668
  timer = setTimeout(() => {
7652
7669
  controller.abort();
7653
- resolve(structuredClone(UNKNOWN_RUNTIME));
7670
+ resolve({ status: "unknown" });
7654
7671
  }, 500);
7655
7672
  })]);
7656
7673
  } catch {
7657
- return structuredClone(UNKNOWN_RUNTIME);
7674
+ return { status: "unknown" };
7658
7675
  } finally {
7659
7676
  if (timer) clearTimeout(timer);
7660
7677
  }
@@ -25141,7 +25158,7 @@ function isRecord(value) {
25141
25158
  }
25142
25159
 
25143
25160
  // packages/cli/src/workPackSyncPlugin.ts
25144
- var PLUGIN_VERSION = "0.1.20";
25161
+ var PLUGIN_VERSION = "0.1.22";
25145
25162
  var STATUS_FILENAME = "work-pack-startup-status.json";
25146
25163
  var activeSync = /* @__PURE__ */ new Map();
25147
25164
  var ForgeWorkPackSyncServer = async (_input, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimal-forge-work-pack-sync",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Minimal Forge Work Pack startup synchronization for OpenCode and OpenWork.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {