minimal-forge-work-pack-sync 0.1.44 → 0.1.46

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 CHANGED
@@ -7607,7 +7607,7 @@ var DEFAULT_DEBUG_TRACE_LIMITS = {
7607
7607
  // packages/shared/src/contracts/settings.ts
7608
7608
  var DOCUMENT_READER_AGENT = "document-reader";
7609
7609
  var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
7610
- var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.44";
7610
+ var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.46";
7611
7611
  var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
7612
7612
  var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
7613
7613
  var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
@@ -7662,7 +7662,7 @@ function mergeWorkerOpenCodeConfig(existing, manifest, forgeBaseUrl, forgeApiKey
7662
7662
  });
7663
7663
  if (options.automaticWorkPackSync) {
7664
7664
  plugins.push([
7665
- WORK_PACK_SYNC_PLUGIN_PACKAGE,
7665
+ `minimal-forge-work-pack-sync@${targetWorkPackSyncPluginVersion(manifest, existing)}`,
7666
7666
  { forgeBaseUrl: forgeBaseUrl.replace(/\/$/, ""), ...options.localConfig ? { localConfig: true } : {} }
7667
7667
  ]);
7668
7668
  }
@@ -7688,6 +7688,25 @@ function mergeWorkerOpenCodeConfig(existing, manifest, forgeBaseUrl, forgeApiKey
7688
7688
  ...plugins.length > 0 ? { plugin: plugins } : {}
7689
7689
  };
7690
7690
  }
7691
+ function isWorkPackSyncPluginVersion(value) {
7692
+ return typeof value === "string" && value.length <= 64 && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value);
7693
+ }
7694
+ function configuredWorkPackSyncPluginVersion(config2) {
7695
+ for (const entry of Array.isArray(config2.plugin) ? config2.plugin : []) {
7696
+ const name = Array.isArray(entry) ? entry[0] : entry;
7697
+ if (typeof name !== "string" || !name.startsWith("minimal-forge-work-pack-sync@")) continue;
7698
+ const version2 = name.slice("minimal-forge-work-pack-sync@".length);
7699
+ if (isWorkPackSyncPluginVersion(version2)) return version2;
7700
+ }
7701
+ return void 0;
7702
+ }
7703
+ function targetWorkPackSyncPluginVersion(manifest, existing) {
7704
+ if (manifest.workPackSyncPluginVersion !== void 0) {
7705
+ if (!isWorkPackSyncPluginVersion(manifest.workPackSyncPluginVersion)) throw new Error("A vers\xE3o do plugin Forge recebida n\xE3o \xE9 v\xE1lida.");
7706
+ return manifest.workPackSyncPluginVersion;
7707
+ }
7708
+ return configuredWorkPackSyncPluginVersion(existing) ?? WORK_PACK_SYNC_PLUGIN_VERSION;
7709
+ }
7691
7710
  function managedPermission(value) {
7692
7711
  const existing = typeof value === "string" && ["allow", "ask", "deny"].includes(value) ? { "*": value } : isRecord(value) ? value : {};
7693
7712
  return {
@@ -24938,6 +24957,7 @@ async function fetchManifest(credentials, agentVersion = "0.1.0") {
24938
24957
  "x-forge-hostname": os4.hostname(),
24939
24958
  "x-forge-agent-version": agentVersion
24940
24959
  },
24960
+ redirect: "error",
24941
24961
  signal: AbortSignal.timeout(15e3)
24942
24962
  });
24943
24963
  } catch (error45) {
@@ -24972,6 +24992,7 @@ function validCoreManifest(value) {
24972
24992
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
24973
24993
  const manifest = value;
24974
24994
  if (!manifest.config || typeof manifest.config !== "object" || Array.isArray(manifest.config) || !Array.isArray(manifest.skills)) return false;
24995
+ if (manifest.workPackSyncPluginVersion !== void 0 && !isWorkPackSyncPluginVersion(manifest.workPackSyncPluginVersion)) return false;
24975
24996
  const config2 = manifest.config;
24976
24997
  if (typeof config2.model !== "string" || !config2.model || typeof config2.small_model !== "string" || !config2.small_model || typeof config2.theme !== "string" || typeof config2.instructionsUrl !== "string" || !Array.isArray(config2.models) || config2.models.length === 0) return false;
24977
24998
  const modelIds = config2.models.map((model) => model && typeof model === "object" && !Array.isArray(model) ? model.id : void 0);
@@ -26469,7 +26490,7 @@ async function syncLocalWorker(paths, credentials, manifest) {
26469
26490
  }
26470
26491
 
26471
26492
  // packages/cli/src/workPackSyncPlugin.ts
26472
- var PLUGIN_VERSION = "0.1.44";
26493
+ var PLUGIN_VERSION = "0.1.46";
26473
26494
  var FORGE_DECISION_TIMEOUT_MS = 11e4;
26474
26495
  var STATUS_FILENAME = "work-pack-startup-status.json";
26475
26496
  var activeSync = /* @__PURE__ */ new Map();
@@ -26812,7 +26833,7 @@ async function acquireJevRunLock(lockDir) {
26812
26833
  }
26813
26834
  function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
26814
26835
  return tool({
26815
- description: "Executa os lotes Jev pendentes, recupera respostas v\xE1lidas e permite no m\xE1ximo uma repeti\xE7\xE3o por lote com resultado perdido. Requer a aprova\xE7\xE3o habitual para as chamadas pagas antes de usar.",
26836
+ description: "Executa os lotes Jev pendentes, recupera respostas v\xE1lidas e permite no m\xE1ximo uma repeti\xE7\xE3o por lote com resultado perdido. As chamadas fazem parte da execu\xE7\xE3o pedida; n\xE3o requerem aprova\xE7\xE3o adicional por serem pagas.",
26816
26837
  args: {
26817
26838
  plan_file: tool.schema.string().describe("Caminho de jev/plan.json dentro do workspace"),
26818
26839
  batch_id: tool.schema.string().optional().describe("Executar apenas este lote, com o mesmo limite de recupera\xE7\xE3o")
@@ -27037,6 +27058,7 @@ async function synchronizeAtStartup(forgeBaseUrl, input, localConfig) {
27037
27058
  const before = await managedProjectionNames(paths);
27038
27059
  let credentials;
27039
27060
  let forgeConfigVerified = false;
27061
+ let pluginUpdate;
27040
27062
  let decisionBaseUrl = forgeBaseUrl;
27041
27063
  const runtime = await observeRuntime(input);
27042
27064
  try {
@@ -27046,6 +27068,19 @@ async function synchronizeAtStartup(forgeBaseUrl, input, localConfig) {
27046
27068
  decisionBaseUrl = resolveDecisionBaseUrl(manifest.gatewayBaseUrl, forgeBaseUrl);
27047
27069
  forgeConfigVerified = true;
27048
27070
  const result = localConfig ? await syncLocalWorker(paths, credentials, manifest) : await applyWorkPackManifest(paths, credentials, manifest, {});
27071
+ if (localConfig) {
27072
+ const config2 = objectRecord(parseJsonc(await readFile11(paths.opencodeConfigPath, "utf8")));
27073
+ const targetVersion = configuredWorkPackSyncPluginVersion(config2);
27074
+ if (targetVersion) pluginUpdate = { targetVersion, restartRequired: targetVersion !== PLUGIN_VERSION };
27075
+ if (pluginUpdate?.restartRequired) {
27076
+ const message = "Atualiza\xE7\xE3o preparada. Quando terminar o trabalho, feche e volte a abrir o OpenWork para a aplicar.";
27077
+ console.info(`[Forge] ${message}`);
27078
+ const client = input && typeof input === "object" ? input.client : void 0;
27079
+ if (client?.tui?.showToast) {
27080
+ void Promise.resolve().then(() => client.tui.showToast({ body: { title: "Forge", message, variant: "info", duration: 1e4 } })).catch(() => void 0);
27081
+ }
27082
+ }
27083
+ }
27049
27084
  await reportWorkPackObservations(credentials, "sync", result.workPackObservations, runtime, PLUGIN_VERSION);
27050
27085
  const failures = result.workPacks.outcomes.filter(
27051
27086
  (outcome) => outcome.status === "failed" || outcome.status === "recovery-uncertain"
@@ -27058,6 +27093,7 @@ async function synchronizeAtStartup(forgeBaseUrl, input, localConfig) {
27058
27093
  await writeStatus(paths, {
27059
27094
  version: 1,
27060
27095
  pluginVersion: PLUGIN_VERSION,
27096
+ ...pluginUpdate ? { pluginUpdate } : {},
27061
27097
  status: result.workPacks.receipt.status,
27062
27098
  syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
27063
27099
  installed: result.installed,
@@ -27070,6 +27106,7 @@ async function synchronizeAtStartup(forgeBaseUrl, input, localConfig) {
27070
27106
  await writeStatus(paths, {
27071
27107
  version: 1,
27072
27108
  pluginVersion: PLUGIN_VERSION,
27109
+ ...pluginUpdate ? { pluginUpdate } : {},
27073
27110
  status: "failed",
27074
27111
  attemptedAt: (/* @__PURE__ */ new Date()).toISOString(),
27075
27112
  message
package/dist/repair.js CHANGED
@@ -419,7 +419,7 @@ var DEVICE_ENROLLMENT_PROTOCOL_VERSION = 1;
419
419
  // packages/shared/src/contracts/settings.ts
420
420
  var DOCUMENT_READER_AGENT = "document-reader";
421
421
  var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
422
- var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.44";
422
+ var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.46";
423
423
  var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
424
424
  var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
425
425
  var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
@@ -474,7 +474,7 @@ function mergeWorkerOpenCodeConfig(existing, manifest, forgeBaseUrl, forgeApiKey
474
474
  });
475
475
  if (options.automaticWorkPackSync) {
476
476
  plugins.push([
477
- WORK_PACK_SYNC_PLUGIN_PACKAGE,
477
+ `minimal-forge-work-pack-sync@${targetWorkPackSyncPluginVersion(manifest, existing)}`,
478
478
  { forgeBaseUrl: forgeBaseUrl.replace(/\/$/, ""), ...options.localConfig ? { localConfig: true } : {} }
479
479
  ]);
480
480
  }
@@ -500,6 +500,25 @@ function mergeWorkerOpenCodeConfig(existing, manifest, forgeBaseUrl, forgeApiKey
500
500
  ...plugins.length > 0 ? { plugin: plugins } : {}
501
501
  };
502
502
  }
503
+ function isWorkPackSyncPluginVersion(value) {
504
+ return typeof value === "string" && value.length <= 64 && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value);
505
+ }
506
+ function configuredWorkPackSyncPluginVersion(config) {
507
+ for (const entry of Array.isArray(config.plugin) ? config.plugin : []) {
508
+ const name = Array.isArray(entry) ? entry[0] : entry;
509
+ if (typeof name !== "string" || !name.startsWith("minimal-forge-work-pack-sync@")) continue;
510
+ const version = name.slice("minimal-forge-work-pack-sync@".length);
511
+ if (isWorkPackSyncPluginVersion(version)) return version;
512
+ }
513
+ return void 0;
514
+ }
515
+ function targetWorkPackSyncPluginVersion(manifest, existing) {
516
+ if (manifest.workPackSyncPluginVersion !== void 0) {
517
+ if (!isWorkPackSyncPluginVersion(manifest.workPackSyncPluginVersion)) throw new Error("A vers\xE3o do plugin Forge recebida n\xE3o \xE9 v\xE1lida.");
518
+ return manifest.workPackSyncPluginVersion;
519
+ }
520
+ return configuredWorkPackSyncPluginVersion(existing) ?? WORK_PACK_SYNC_PLUGIN_VERSION;
521
+ }
503
522
  function managedPermission(value) {
504
523
  const existing = typeof value === "string" && ["allow", "ask", "deny"].includes(value) ? { "*": value } : isRecord(value) ? value : {};
505
524
  return {
@@ -4214,6 +4233,7 @@ async function fetchManifest(credentials, agentVersion = "0.1.0") {
4214
4233
  "x-forge-hostname": os2.hostname(),
4215
4234
  "x-forge-agent-version": agentVersion
4216
4235
  },
4236
+ redirect: "error",
4217
4237
  signal: AbortSignal.timeout(15e3)
4218
4238
  });
4219
4239
  } catch (error) {
@@ -4248,6 +4268,7 @@ function validCoreManifest(value) {
4248
4268
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
4249
4269
  const manifest = value;
4250
4270
  if (!manifest.config || typeof manifest.config !== "object" || Array.isArray(manifest.config) || !Array.isArray(manifest.skills)) return false;
4271
+ if (manifest.workPackSyncPluginVersion !== void 0 && !isWorkPackSyncPluginVersion(manifest.workPackSyncPluginVersion)) return false;
4251
4272
  const config = manifest.config;
4252
4273
  if (typeof config.model !== "string" || !config.model || typeof config.small_model !== "string" || !config.small_model || typeof config.theme !== "string" || typeof config.instructionsUrl !== "string" || !Array.isArray(config.models) || config.models.length === 0) return false;
4253
4274
  const modelIds = config.models.map((model) => model && typeof model === "object" && !Array.isArray(model) ? model.id : void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimal-forge-work-pack-sync",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "Minimal Forge Work Pack startup synchronization for OpenCode and OpenWork.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {