minimal-forge-work-pack-sync 0.1.55 → 0.1.57

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
@@ -117,17 +117,17 @@ var require_visit = __commonJS({
117
117
  visit.BREAK = BREAK;
118
118
  visit.SKIP = SKIP;
119
119
  visit.REMOVE = REMOVE;
120
- function visit_(key, node, visitor, path16) {
121
- const ctrl = callVisitor(key, node, visitor, path16);
120
+ function visit_(key, node, visitor, path18) {
121
+ const ctrl = callVisitor(key, node, visitor, path18);
122
122
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
123
- replaceNode(key, path16, ctrl);
124
- return visit_(key, ctrl, visitor, path16);
123
+ replaceNode(key, path18, ctrl);
124
+ return visit_(key, ctrl, visitor, path18);
125
125
  }
126
126
  if (typeof ctrl !== "symbol") {
127
127
  if (identity.isCollection(node)) {
128
- path16 = Object.freeze(path16.concat(node));
128
+ path18 = Object.freeze(path18.concat(node));
129
129
  for (let i = 0; i < node.items.length; ++i) {
130
- const ci2 = visit_(i, node.items[i], visitor, path16);
130
+ const ci2 = visit_(i, node.items[i], visitor, path18);
131
131
  if (typeof ci2 === "number")
132
132
  i = ci2 - 1;
133
133
  else if (ci2 === BREAK)
@@ -138,13 +138,13 @@ var require_visit = __commonJS({
138
138
  }
139
139
  }
140
140
  } else if (identity.isPair(node)) {
141
- path16 = Object.freeze(path16.concat(node));
142
- const ck = visit_("key", node.key, visitor, path16);
141
+ path18 = Object.freeze(path18.concat(node));
142
+ const ck = visit_("key", node.key, visitor, path18);
143
143
  if (ck === BREAK)
144
144
  return BREAK;
145
145
  else if (ck === REMOVE)
146
146
  node.key = null;
147
- const cv = visit_("value", node.value, visitor, path16);
147
+ const cv = visit_("value", node.value, visitor, path18);
148
148
  if (cv === BREAK)
149
149
  return BREAK;
150
150
  else if (cv === REMOVE)
@@ -165,17 +165,17 @@ var require_visit = __commonJS({
165
165
  visitAsync.BREAK = BREAK;
166
166
  visitAsync.SKIP = SKIP;
167
167
  visitAsync.REMOVE = REMOVE;
168
- async function visitAsync_(key, node, visitor, path16) {
169
- const ctrl = await callVisitor(key, node, visitor, path16);
168
+ async function visitAsync_(key, node, visitor, path18) {
169
+ const ctrl = await callVisitor(key, node, visitor, path18);
170
170
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
171
- replaceNode(key, path16, ctrl);
172
- return visitAsync_(key, ctrl, visitor, path16);
171
+ replaceNode(key, path18, ctrl);
172
+ return visitAsync_(key, ctrl, visitor, path18);
173
173
  }
174
174
  if (typeof ctrl !== "symbol") {
175
175
  if (identity.isCollection(node)) {
176
- path16 = Object.freeze(path16.concat(node));
176
+ path18 = Object.freeze(path18.concat(node));
177
177
  for (let i = 0; i < node.items.length; ++i) {
178
- const ci2 = await visitAsync_(i, node.items[i], visitor, path16);
178
+ const ci2 = await visitAsync_(i, node.items[i], visitor, path18);
179
179
  if (typeof ci2 === "number")
180
180
  i = ci2 - 1;
181
181
  else if (ci2 === BREAK)
@@ -186,13 +186,13 @@ var require_visit = __commonJS({
186
186
  }
187
187
  }
188
188
  } else if (identity.isPair(node)) {
189
- path16 = Object.freeze(path16.concat(node));
190
- const ck = await visitAsync_("key", node.key, visitor, path16);
189
+ path18 = Object.freeze(path18.concat(node));
190
+ const ck = await visitAsync_("key", node.key, visitor, path18);
191
191
  if (ck === BREAK)
192
192
  return BREAK;
193
193
  else if (ck === REMOVE)
194
194
  node.key = null;
195
- const cv = await visitAsync_("value", node.value, visitor, path16);
195
+ const cv = await visitAsync_("value", node.value, visitor, path18);
196
196
  if (cv === BREAK)
197
197
  return BREAK;
198
198
  else if (cv === REMOVE)
@@ -219,23 +219,23 @@ var require_visit = __commonJS({
219
219
  }
220
220
  return visitor;
221
221
  }
222
- function callVisitor(key, node, visitor, path16) {
222
+ function callVisitor(key, node, visitor, path18) {
223
223
  if (typeof visitor === "function")
224
- return visitor(key, node, path16);
224
+ return visitor(key, node, path18);
225
225
  if (identity.isMap(node))
226
- return visitor.Map?.(key, node, path16);
226
+ return visitor.Map?.(key, node, path18);
227
227
  if (identity.isSeq(node))
228
- return visitor.Seq?.(key, node, path16);
228
+ return visitor.Seq?.(key, node, path18);
229
229
  if (identity.isPair(node))
230
- return visitor.Pair?.(key, node, path16);
230
+ return visitor.Pair?.(key, node, path18);
231
231
  if (identity.isScalar(node))
232
- return visitor.Scalar?.(key, node, path16);
232
+ return visitor.Scalar?.(key, node, path18);
233
233
  if (identity.isAlias(node))
234
- return visitor.Alias?.(key, node, path16);
234
+ return visitor.Alias?.(key, node, path18);
235
235
  return void 0;
236
236
  }
237
- function replaceNode(key, path16, node) {
238
- const parent = path16[path16.length - 1];
237
+ function replaceNode(key, path18, node) {
238
+ const parent = path18[path18.length - 1];
239
239
  if (identity.isCollection(parent)) {
240
240
  parent.items[key] = node;
241
241
  } else if (identity.isPair(parent)) {
@@ -847,10 +847,10 @@ var require_Collection = __commonJS({
847
847
  var createNode = require_createNode();
848
848
  var identity = require_identity();
849
849
  var Node = require_Node();
850
- function collectionFromPath(schema, path16, value) {
850
+ function collectionFromPath(schema, path18, value) {
851
851
  let v2 = value;
852
- for (let i = path16.length - 1; i >= 0; --i) {
853
- const k2 = path16[i];
852
+ for (let i = path18.length - 1; i >= 0; --i) {
853
+ const k2 = path18[i];
854
854
  if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
855
855
  const a = [];
856
856
  a[k2] = v2;
@@ -869,7 +869,7 @@ var require_Collection = __commonJS({
869
869
  sourceObjects: /* @__PURE__ */ new Map()
870
870
  });
871
871
  }
872
- var isEmptyPath = (path16) => path16 == null || typeof path16 === "object" && !!path16[Symbol.iterator]().next().done;
872
+ var isEmptyPath = (path18) => path18 == null || typeof path18 === "object" && !!path18[Symbol.iterator]().next().done;
873
873
  var Collection = class extends Node.NodeBase {
874
874
  constructor(type, schema) {
875
875
  super(type);
@@ -899,11 +899,11 @@ var require_Collection = __commonJS({
899
899
  * be a Pair instance or a `{ key, value }` object, which may not have a key
900
900
  * that already exists in the map.
901
901
  */
902
- addIn(path16, value) {
903
- if (isEmptyPath(path16))
902
+ addIn(path18, value) {
903
+ if (isEmptyPath(path18))
904
904
  this.add(value);
905
905
  else {
906
- const [key, ...rest] = path16;
906
+ const [key, ...rest] = path18;
907
907
  const node = this.get(key, true);
908
908
  if (identity.isCollection(node))
909
909
  node.addIn(rest, value);
@@ -917,8 +917,8 @@ var require_Collection = __commonJS({
917
917
  * Removes a value from the collection.
918
918
  * @returns `true` if the item was found and removed.
919
919
  */
920
- deleteIn(path16) {
921
- const [key, ...rest] = path16;
920
+ deleteIn(path18) {
921
+ const [key, ...rest] = path18;
922
922
  if (rest.length === 0)
923
923
  return this.delete(key);
924
924
  const node = this.get(key, true);
@@ -932,8 +932,8 @@ var require_Collection = __commonJS({
932
932
  * scalar values from their surrounding node; to disable set `keepScalar` to
933
933
  * `true` (collections are always returned intact).
934
934
  */
935
- getIn(path16, keepScalar) {
936
- const [key, ...rest] = path16;
935
+ getIn(path18, keepScalar) {
936
+ const [key, ...rest] = path18;
937
937
  const node = this.get(key, true);
938
938
  if (rest.length === 0)
939
939
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -951,8 +951,8 @@ var require_Collection = __commonJS({
951
951
  /**
952
952
  * Checks if the collection includes a value with the key `key`.
953
953
  */
954
- hasIn(path16) {
955
- const [key, ...rest] = path16;
954
+ hasIn(path18) {
955
+ const [key, ...rest] = path18;
956
956
  if (rest.length === 0)
957
957
  return this.has(key);
958
958
  const node = this.get(key, true);
@@ -962,8 +962,8 @@ var require_Collection = __commonJS({
962
962
  * Sets a value in this collection. For `!!set`, `value` needs to be a
963
963
  * boolean to add/remove the item from the set.
964
964
  */
965
- setIn(path16, value) {
966
- const [key, ...rest] = path16;
965
+ setIn(path18, value) {
966
+ const [key, ...rest] = path18;
967
967
  if (rest.length === 0) {
968
968
  this.set(key, value);
969
969
  } else {
@@ -3478,9 +3478,9 @@ var require_Document = __commonJS({
3478
3478
  this.contents.add(value);
3479
3479
  }
3480
3480
  /** Adds a value to the document. */
3481
- addIn(path16, value) {
3481
+ addIn(path18, value) {
3482
3482
  if (assertCollection(this.contents))
3483
- this.contents.addIn(path16, value);
3483
+ this.contents.addIn(path18, value);
3484
3484
  }
3485
3485
  /**
3486
3486
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3555,14 +3555,14 @@ var require_Document = __commonJS({
3555
3555
  * Removes a value from the document.
3556
3556
  * @returns `true` if the item was found and removed.
3557
3557
  */
3558
- deleteIn(path16) {
3559
- if (Collection.isEmptyPath(path16)) {
3558
+ deleteIn(path18) {
3559
+ if (Collection.isEmptyPath(path18)) {
3560
3560
  if (this.contents == null)
3561
3561
  return false;
3562
3562
  this.contents = null;
3563
3563
  return true;
3564
3564
  }
3565
- return assertCollection(this.contents) ? this.contents.deleteIn(path16) : false;
3565
+ return assertCollection(this.contents) ? this.contents.deleteIn(path18) : false;
3566
3566
  }
3567
3567
  /**
3568
3568
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3577,10 +3577,10 @@ var require_Document = __commonJS({
3577
3577
  * scalar values from their surrounding node; to disable set `keepScalar` to
3578
3578
  * `true` (collections are always returned intact).
3579
3579
  */
3580
- getIn(path16, keepScalar) {
3581
- if (Collection.isEmptyPath(path16))
3580
+ getIn(path18, keepScalar) {
3581
+ if (Collection.isEmptyPath(path18))
3582
3582
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3583
- return identity.isCollection(this.contents) ? this.contents.getIn(path16, keepScalar) : void 0;
3583
+ return identity.isCollection(this.contents) ? this.contents.getIn(path18, keepScalar) : void 0;
3584
3584
  }
3585
3585
  /**
3586
3586
  * Checks if the document includes a value with the key `key`.
@@ -3591,10 +3591,10 @@ var require_Document = __commonJS({
3591
3591
  /**
3592
3592
  * Checks if the document includes a value at `path`.
3593
3593
  */
3594
- hasIn(path16) {
3595
- if (Collection.isEmptyPath(path16))
3594
+ hasIn(path18) {
3595
+ if (Collection.isEmptyPath(path18))
3596
3596
  return this.contents !== void 0;
3597
- return identity.isCollection(this.contents) ? this.contents.hasIn(path16) : false;
3597
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path18) : false;
3598
3598
  }
3599
3599
  /**
3600
3600
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3611,13 +3611,13 @@ var require_Document = __commonJS({
3611
3611
  * Sets a value in this document. For `!!set`, `value` needs to be a
3612
3612
  * boolean to add/remove the item from the set.
3613
3613
  */
3614
- setIn(path16, value) {
3615
- if (Collection.isEmptyPath(path16)) {
3614
+ setIn(path18, value) {
3615
+ if (Collection.isEmptyPath(path18)) {
3616
3616
  this.contents = value;
3617
3617
  } else if (this.contents == null) {
3618
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path16), value);
3618
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path18), value);
3619
3619
  } else if (assertCollection(this.contents)) {
3620
- this.contents.setIn(path16, value);
3620
+ this.contents.setIn(path18, value);
3621
3621
  }
3622
3622
  }
3623
3623
  /**
@@ -5578,9 +5578,9 @@ var require_cst_visit = __commonJS({
5578
5578
  visit.BREAK = BREAK;
5579
5579
  visit.SKIP = SKIP;
5580
5580
  visit.REMOVE = REMOVE;
5581
- visit.itemAtPath = (cst, path16) => {
5581
+ visit.itemAtPath = (cst, path18) => {
5582
5582
  let item = cst;
5583
- for (const [field, index] of path16) {
5583
+ for (const [field, index] of path18) {
5584
5584
  const tok = item?.[field];
5585
5585
  if (tok && "items" in tok) {
5586
5586
  item = tok.items[index];
@@ -5589,23 +5589,23 @@ var require_cst_visit = __commonJS({
5589
5589
  }
5590
5590
  return item;
5591
5591
  };
5592
- visit.parentCollection = (cst, path16) => {
5593
- const parent = visit.itemAtPath(cst, path16.slice(0, -1));
5594
- const field = path16[path16.length - 1][0];
5592
+ visit.parentCollection = (cst, path18) => {
5593
+ const parent = visit.itemAtPath(cst, path18.slice(0, -1));
5594
+ const field = path18[path18.length - 1][0];
5595
5595
  const coll = parent?.[field];
5596
5596
  if (coll && "items" in coll)
5597
5597
  return coll;
5598
5598
  throw new Error("Parent collection not found");
5599
5599
  };
5600
- function _visit(path16, item, visitor) {
5601
- let ctrl = visitor(item, path16);
5600
+ function _visit(path18, item, visitor) {
5601
+ let ctrl = visitor(item, path18);
5602
5602
  if (typeof ctrl === "symbol")
5603
5603
  return ctrl;
5604
5604
  for (const field of ["key", "value"]) {
5605
5605
  const token = item[field];
5606
5606
  if (token && "items" in token) {
5607
5607
  for (let i = 0; i < token.items.length; ++i) {
5608
- const ci2 = _visit(Object.freeze(path16.concat([[field, i]])), token.items[i], visitor);
5608
+ const ci2 = _visit(Object.freeze(path18.concat([[field, i]])), token.items[i], visitor);
5609
5609
  if (typeof ci2 === "number")
5610
5610
  i = ci2 - 1;
5611
5611
  else if (ci2 === BREAK)
@@ -5616,10 +5616,10 @@ var require_cst_visit = __commonJS({
5616
5616
  }
5617
5617
  }
5618
5618
  if (typeof ctrl === "function" && field === "key")
5619
- ctrl = ctrl(item, path16);
5619
+ ctrl = ctrl(item, path18);
5620
5620
  }
5621
5621
  }
5622
- return typeof ctrl === "function" ? ctrl(item, path16) : ctrl;
5622
+ return typeof ctrl === "function" ? ctrl(item, path18) : ctrl;
5623
5623
  }
5624
5624
  exports.visit = visit;
5625
5625
  }
@@ -7615,7 +7615,7 @@ var WORKER_FEEDBACK_MAX_MESSAGE_LENGTH = 24e3;
7615
7615
  // packages/shared/src/contracts/settings.ts
7616
7616
  var DOCUMENT_READER_AGENT = "document-reader";
7617
7617
  var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
7618
- var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.55";
7618
+ var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.57";
7619
7619
  var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
7620
7620
  var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
7621
7621
  var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
@@ -7770,6 +7770,20 @@ function normalizeGatewayBaseUrl(value) {
7770
7770
  return url2.origin;
7771
7771
  }
7772
7772
 
7773
+ // packages/shared/src/pythonRequirements.ts
7774
+ var PYTHON_REQUIREMENTS = [
7775
+ { name: "pandas", importName: "pandas", requirement: "pandas>=2.1,<3" },
7776
+ { name: "numpy", importName: "numpy", requirement: "numpy>=1.26,<3" },
7777
+ { name: "scipy", importName: "scipy", requirement: "scipy>=1.11,<2" },
7778
+ { name: "openpyxl", importName: "openpyxl", requirement: "openpyxl>=3.1,<4" },
7779
+ { name: "pyreadstat", importName: "pyreadstat", requirement: "pyreadstat>=1.2,<2" },
7780
+ { name: "python-docx", importName: "docx", requirement: "python-docx>=1.1,<2" },
7781
+ { name: "python-pptx", importName: "pptx", requirement: "python-pptx>=1,<2" },
7782
+ { name: "pypdf", importName: "pypdf", requirement: "pypdf>=5,<8" },
7783
+ { name: "PyYAML", importName: "yaml", requirement: "PyYAML>=6,<7" },
7784
+ { name: "Pillow", importName: "PIL", requirement: "Pillow>=10,<13" }
7785
+ ];
7786
+
7773
7787
  // packages/shared/src/workPackBaseline.ts
7774
7788
  function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
7775
7789
  return normalizeExtensionModel(pathLabel, content, slug, (modelId) => approvedModelIds.has(modelId));
@@ -7882,12 +7896,12 @@ async function projectCurrentExtensions(config2, state) {
7882
7896
  config2.agent = agents;
7883
7897
  config2.command = commands;
7884
7898
  }
7885
- async function refreshPartialProjections(config2, previous, paths, before, result) {
7899
+ async function refreshPartialProjections(config2, previous, paths, before, result2) {
7886
7900
  const existing = objectRecord(previous);
7887
7901
  const agents = objectRecord(existing.agent);
7888
7902
  const commands = objectRecord(existing.command);
7889
7903
  if (!before.agents.has(DOCUMENT_READER_AGENT)) delete agents[DOCUMENT_READER_AGENT];
7890
- for (const file2 of result.removedManagedPaths) {
7904
+ for (const file2 of result2.removedManagedPaths) {
7891
7905
  if (path.extname(file2) !== ".md") continue;
7892
7906
  const directory = path.dirname(file2);
7893
7907
  const name = path.basename(file2, ".md");
@@ -7896,7 +7910,7 @@ async function refreshPartialProjections(config2, previous, paths, before, resul
7896
7910
  }
7897
7911
  config2.agent = { ...objectRecord(config2.agent), ...agents };
7898
7912
  config2.command = commands;
7899
- const confirmed = new Set(result.workPacks.outcomes.filter(
7913
+ const confirmed = new Set(result2.workPacks.outcomes.filter(
7900
7914
  ({ action, status }) => action === "install" && (status === "installed" || status === "unchanged")
7901
7915
  ).map(({ slug }) => slug));
7902
7916
  await projectInstalledExtensions(config2, paths, confirmed);
@@ -7997,12 +8011,12 @@ async function protectOwnerOnlyPath(filePath, kind, options = {}) {
7997
8011
  }
7998
8012
  const spawn = options.spawnSync ?? nodeSpawnSync;
7999
8013
  const command = kind === "directory" ? "$ErrorActionPreference = 'Stop'; $path = [Console]::In.ReadToEnd(); $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().User; $acl = [System.Security.AccessControl.DirectorySecurity]::new(); $acl.SetAccessRuleProtection($true, $false); $inheritance = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit; $rule = [System.Security.AccessControl.FileSystemAccessRule]::new($identity, [System.Security.AccessControl.FileSystemRights]::FullControl, $inheritance, [System.Security.AccessControl.PropagationFlags]::None, [System.Security.AccessControl.AccessControlType]::Allow); [void]$acl.AddAccessRule($rule); [System.IO.Directory]::SetAccessControl($path, $acl)" : "$ErrorActionPreference = 'Stop'; $path = [Console]::In.ReadToEnd(); $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().User; $acl = [System.Security.AccessControl.FileSecurity]::new(); $acl.SetAccessRuleProtection($true, $false); $rule = [System.Security.AccessControl.FileSystemAccessRule]::new($identity, [System.Security.AccessControl.FileSystemRights]::FullControl, [System.Security.AccessControl.AccessControlType]::Allow); [void]$acl.AddAccessRule($rule); [System.IO.File]::SetAccessControl($path, $acl)";
8000
- const result = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], {
8014
+ const result2 = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], {
8001
8015
  encoding: "utf8",
8002
8016
  input: filePath
8003
8017
  });
8004
- if (result.status !== 0) {
8005
- const detail = typeof result.stderr === "string" ? result.stderr.trim().replace(/\s+/g, " ").slice(0, 500) : "";
8018
+ if (result2.status !== 0) {
8019
+ const detail = typeof result2.stderr === "string" ? result2.stderr.trim().replace(/\s+/g, " ").slice(0, 500) : "";
8006
8020
  const context = options.failureContext ?? (kind === "directory" ? "o diret\xF3rio" : "o ficheiro");
8007
8021
  throw new Error(`N\xE3o foi poss\xEDvel proteger ${context} em ${filePath}${detail ? `: ${detail}` : ""}`);
8008
8022
  }
@@ -8020,12 +8034,12 @@ async function assertExistingDirectoryIsSafe(directory, options) {
8020
8034
  }
8021
8035
  const spawn = options.spawnSync ?? nodeSpawnSync;
8022
8036
  const command = "$ErrorActionPreference = 'Stop'; $path = [Console]::In.ReadToEnd(); $current = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value; $trusted = @($current, 'S-1-5-18', 'S-1-5-32-544'); $dangerous = [System.Security.AccessControl.FileSystemRights]::Write -bor [System.Security.AccessControl.FileSystemRights]::Delete -bor [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles -bor [System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor [System.Security.AccessControl.FileSystemRights]::TakeOwnership; $acl = [System.IO.Directory]::GetAccessControl($path); $rules = $acl.GetAccessRules($true, $true, [System.Security.Principal.SecurityIdentifier]); foreach ($rule in $rules) { if ($rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and $rule.PropagationFlags -ne [System.Security.AccessControl.PropagationFlags]::InheritOnly -and ($rule.FileSystemRights -band $dangerous) -ne 0 -and $trusted -notcontains $rule.IdentityReference.Value) { throw ('O diret\xF3rio permite escrita por ' + $rule.IdentityReference.Value) } }";
8023
- const result = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], {
8037
+ const result2 = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], {
8024
8038
  encoding: "utf8",
8025
8039
  input: directory
8026
8040
  });
8027
- if (result.status !== 0) {
8028
- const detail = typeof result.stderr === "string" ? result.stderr.trim().replace(/\s+/g, " ").slice(0, 500) : "";
8041
+ if (result2.status !== 0) {
8042
+ const detail = typeof result2.stderr === "string" ? result2.stderr.trim().replace(/\s+/g, " ").slice(0, 500) : "";
8029
8043
  throw new Error(`O diret\xF3rio existente ${directory} n\xE3o \xE9 controlado apenas pelo utilizador atual${detail ? `: ${detail}` : ""}`);
8030
8044
  }
8031
8045
  }
@@ -8069,7 +8083,7 @@ async function writeOwnerOnlyTextAtomic(filePath, content, options = {}) {
8069
8083
  }
8070
8084
 
8071
8085
  // packages/cli/src/workPackSyncPlugin.ts
8072
- import { createHash as createHash8, randomUUID as randomUUID5 } from "node:crypto";
8086
+ import { createHash as createHash10, randomUUID as randomUUID6 } from "node:crypto";
8073
8087
  import { pathToFileURL } from "node:url";
8074
8088
 
8075
8089
  // packages/cli/src/skillUsageReporter.ts
@@ -9310,10 +9324,10 @@ function mergeDefs(...defs) {
9310
9324
  function cloneDef(schema) {
9311
9325
  return mergeDefs(schema._zod.def);
9312
9326
  }
9313
- function getElementAtPath(obj, path16) {
9314
- if (!path16)
9327
+ function getElementAtPath(obj, path18) {
9328
+ if (!path18)
9315
9329
  return obj;
9316
- return path16.reduce((acc, key) => acc?.[key], obj);
9330
+ return path18.reduce((acc, key) => acc?.[key], obj);
9317
9331
  }
9318
9332
  function promiseAllObject(promisesObj) {
9319
9333
  const keys = Object.keys(promisesObj);
@@ -9674,11 +9688,11 @@ function aborted(x, startIndex = 0) {
9674
9688
  }
9675
9689
  return false;
9676
9690
  }
9677
- function prefixIssues(path16, issues) {
9691
+ function prefixIssues(path18, issues) {
9678
9692
  return issues.map((iss) => {
9679
9693
  var _a;
9680
9694
  (_a = iss).path ?? (_a.path = []);
9681
- iss.path.unshift(path16);
9695
+ iss.path.unshift(path18);
9682
9696
  return iss;
9683
9697
  });
9684
9698
  }
@@ -9845,8 +9859,8 @@ function treeifyError(error45, _mapper) {
9845
9859
  const mapper = _mapper || function(issue2) {
9846
9860
  return issue2.message;
9847
9861
  };
9848
- const result = { errors: [] };
9849
- const processError = (error46, path16 = []) => {
9862
+ const result2 = { errors: [] };
9863
+ const processError = (error46, path18 = []) => {
9850
9864
  var _a, _b;
9851
9865
  for (const issue2 of error46.issues) {
9852
9866
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -9856,12 +9870,12 @@ function treeifyError(error45, _mapper) {
9856
9870
  } else if (issue2.code === "invalid_element") {
9857
9871
  processError({ issues: issue2.issues }, issue2.path);
9858
9872
  } else {
9859
- const fullpath = [...path16, ...issue2.path];
9873
+ const fullpath = [...path18, ...issue2.path];
9860
9874
  if (fullpath.length === 0) {
9861
- result.errors.push(mapper(issue2));
9875
+ result2.errors.push(mapper(issue2));
9862
9876
  continue;
9863
9877
  }
9864
- let curr = result;
9878
+ let curr = result2;
9865
9879
  let i = 0;
9866
9880
  while (i < fullpath.length) {
9867
9881
  const el = fullpath[i];
@@ -9884,12 +9898,12 @@ function treeifyError(error45, _mapper) {
9884
9898
  }
9885
9899
  };
9886
9900
  processError(error45);
9887
- return result;
9901
+ return result2;
9888
9902
  }
9889
9903
  function toDotPath(_path) {
9890
9904
  const segs = [];
9891
- const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
9892
- for (const seg of path16) {
9905
+ const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
9906
+ for (const seg of path18) {
9893
9907
  if (typeof seg === "number")
9894
9908
  segs.push(`[${seg}]`);
9895
9909
  else if (typeof seg === "symbol")
@@ -9918,52 +9932,52 @@ function prettifyError(error45) {
9918
9932
  // node_modules/@opencode-ai/plugin/node_modules/zod/v4/core/parse.js
9919
9933
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
9920
9934
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
9921
- const result = schema._zod.run({ value, issues: [] }, ctx);
9922
- if (result instanceof Promise) {
9935
+ const result2 = schema._zod.run({ value, issues: [] }, ctx);
9936
+ if (result2 instanceof Promise) {
9923
9937
  throw new $ZodAsyncError();
9924
9938
  }
9925
- if (result.issues.length) {
9926
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9939
+ if (result2.issues.length) {
9940
+ const e = new (_params?.Err ?? _Err)(result2.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9927
9941
  captureStackTrace(e, _params?.callee);
9928
9942
  throw e;
9929
9943
  }
9930
- return result.value;
9944
+ return result2.value;
9931
9945
  };
9932
9946
  var parse = /* @__PURE__ */ _parse($ZodRealError);
9933
9947
  var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
9934
9948
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
9935
- let result = schema._zod.run({ value, issues: [] }, ctx);
9936
- if (result instanceof Promise)
9937
- result = await result;
9938
- if (result.issues.length) {
9939
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9949
+ let result2 = schema._zod.run({ value, issues: [] }, ctx);
9950
+ if (result2 instanceof Promise)
9951
+ result2 = await result2;
9952
+ if (result2.issues.length) {
9953
+ const e = new (params?.Err ?? _Err)(result2.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9940
9954
  captureStackTrace(e, params?.callee);
9941
9955
  throw e;
9942
9956
  }
9943
- return result.value;
9957
+ return result2.value;
9944
9958
  };
9945
9959
  var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
9946
9960
  var _safeParse = (_Err) => (schema, value, _ctx) => {
9947
9961
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
9948
- const result = schema._zod.run({ value, issues: [] }, ctx);
9949
- if (result instanceof Promise) {
9962
+ const result2 = schema._zod.run({ value, issues: [] }, ctx);
9963
+ if (result2 instanceof Promise) {
9950
9964
  throw new $ZodAsyncError();
9951
9965
  }
9952
- return result.issues.length ? {
9966
+ return result2.issues.length ? {
9953
9967
  success: false,
9954
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
9955
- } : { success: true, data: result.value };
9968
+ error: new (_Err ?? $ZodError)(result2.issues.map((iss) => finalizeIssue(iss, ctx, config())))
9969
+ } : { success: true, data: result2.value };
9956
9970
  };
9957
9971
  var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
9958
9972
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
9959
9973
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
9960
- let result = schema._zod.run({ value, issues: [] }, ctx);
9961
- if (result instanceof Promise)
9962
- result = await result;
9963
- return result.issues.length ? {
9974
+ let result2 = schema._zod.run({ value, issues: [] }, ctx);
9975
+ if (result2 instanceof Promise)
9976
+ result2 = await result2;
9977
+ return result2.issues.length ? {
9964
9978
  success: false,
9965
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
9966
- } : { success: true, data: result.value };
9979
+ error: new _Err(result2.issues.map((iss) => finalizeIssue(iss, ctx, config())))
9980
+ } : { success: true, data: result2.value };
9967
9981
  };
9968
9982
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
9969
9983
  var _encode = (_Err) => (schema, value, _ctx) => {
@@ -10653,22 +10667,22 @@ var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst,
10653
10667
  });
10654
10668
  };
10655
10669
  });
10656
- function handleCheckPropertyResult(result, payload, property) {
10657
- if (result.issues.length) {
10658
- payload.issues.push(...prefixIssues(property, result.issues));
10670
+ function handleCheckPropertyResult(result2, payload, property) {
10671
+ if (result2.issues.length) {
10672
+ payload.issues.push(...prefixIssues(property, result2.issues));
10659
10673
  }
10660
10674
  }
10661
10675
  var $ZodCheckProperty = /* @__PURE__ */ $constructor("$ZodCheckProperty", (inst, def) => {
10662
10676
  $ZodCheck.init(inst, def);
10663
10677
  inst._zod.check = (payload) => {
10664
- const result = def.schema._zod.run({
10678
+ const result2 = def.schema._zod.run({
10665
10679
  value: payload.value[def.property],
10666
10680
  issues: []
10667
10681
  }, {});
10668
- if (result instanceof Promise) {
10669
- return result.then((result2) => handleCheckPropertyResult(result2, payload, def.property));
10682
+ if (result2 instanceof Promise) {
10683
+ return result2.then((result3) => handleCheckPropertyResult(result3, payload, def.property));
10670
10684
  }
10671
- handleCheckPropertyResult(result, payload, def.property);
10685
+ handleCheckPropertyResult(result2, payload, def.property);
10672
10686
  return;
10673
10687
  };
10674
10688
  });
@@ -10828,13 +10842,13 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
10828
10842
  }
10829
10843
  return handleCanaryResult(canary, payload, ctx);
10830
10844
  }
10831
- const result = inst._zod.parse(payload, ctx);
10832
- if (result instanceof Promise) {
10845
+ const result2 = inst._zod.parse(payload, ctx);
10846
+ if (result2 instanceof Promise) {
10833
10847
  if (ctx.async === false)
10834
10848
  throw new $ZodAsyncError();
10835
- return result.then((result2) => runChecks(result2, checks, ctx));
10849
+ return result2.then((result3) => runChecks(result3, checks, ctx));
10836
10850
  }
10837
- return runChecks(result, checks, ctx);
10851
+ return runChecks(result2, checks, ctx);
10838
10852
  };
10839
10853
  }
10840
10854
  inst["~standard"] = {
@@ -11348,11 +11362,11 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
11348
11362
  return payload;
11349
11363
  };
11350
11364
  });
11351
- function handleArrayResult(result, final, index) {
11352
- if (result.issues.length) {
11353
- final.issues.push(...prefixIssues(index, result.issues));
11365
+ function handleArrayResult(result2, final, index) {
11366
+ if (result2.issues.length) {
11367
+ final.issues.push(...prefixIssues(index, result2.issues));
11354
11368
  }
11355
- final.value[index] = result.value;
11369
+ final.value[index] = result2.value;
11356
11370
  }
11357
11371
  var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
11358
11372
  $ZodType.init(inst, def);
@@ -11371,14 +11385,14 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
11371
11385
  const proms = [];
11372
11386
  for (let i = 0; i < input.length; i++) {
11373
11387
  const item = input[i];
11374
- const result = def.element._zod.run({
11388
+ const result2 = def.element._zod.run({
11375
11389
  value: item,
11376
11390
  issues: []
11377
11391
  }, ctx);
11378
- if (result instanceof Promise) {
11379
- proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
11392
+ if (result2 instanceof Promise) {
11393
+ proms.push(result2.then((result3) => handleArrayResult(result3, payload, i)));
11380
11394
  } else {
11381
- handleArrayResult(result, payload, i);
11395
+ handleArrayResult(result2, payload, i);
11382
11396
  }
11383
11397
  }
11384
11398
  if (proms.length) {
@@ -11387,16 +11401,16 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
11387
11401
  return payload;
11388
11402
  };
11389
11403
  });
11390
- function handlePropertyResult(result, final, key, input) {
11391
- if (result.issues.length) {
11392
- final.issues.push(...prefixIssues(key, result.issues));
11404
+ function handlePropertyResult(result2, final, key, input) {
11405
+ if (result2.issues.length) {
11406
+ final.issues.push(...prefixIssues(key, result2.issues));
11393
11407
  }
11394
- if (result.value === void 0) {
11408
+ if (result2.value === void 0) {
11395
11409
  if (key in input) {
11396
11410
  final.value[key] = void 0;
11397
11411
  }
11398
11412
  } else {
11399
- final.value[key] = result.value;
11413
+ final.value[key] = result2.value;
11400
11414
  }
11401
11415
  }
11402
11416
  function normalizeDef(def) {
@@ -11574,9 +11588,9 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
11574
11588
  };
11575
11589
  });
11576
11590
  function handleUnionResults(results, final, inst, ctx) {
11577
- for (const result of results) {
11578
- if (result.issues.length === 0) {
11579
- final.value = result.value;
11591
+ for (const result2 of results) {
11592
+ if (result2.issues.length === 0) {
11593
+ final.value = result2.value;
11580
11594
  return final;
11581
11595
  }
11582
11596
  }
@@ -11589,7 +11603,7 @@ function handleUnionResults(results, final, inst, ctx) {
11589
11603
  code: "invalid_union",
11590
11604
  input: final.value,
11591
11605
  inst,
11592
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
11606
+ errors: results.map((result2) => result2.issues.map((iss) => finalizeIssue(iss, ctx, config())))
11593
11607
  });
11594
11608
  return final;
11595
11609
  }
@@ -11619,17 +11633,17 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
11619
11633
  let async = false;
11620
11634
  const results = [];
11621
11635
  for (const option of def.options) {
11622
- const result = option._zod.run({
11636
+ const result2 = option._zod.run({
11623
11637
  value: payload.value,
11624
11638
  issues: []
11625
11639
  }, ctx);
11626
- if (result instanceof Promise) {
11627
- results.push(result);
11640
+ if (result2 instanceof Promise) {
11641
+ results.push(result2);
11628
11642
  async = true;
11629
11643
  } else {
11630
- if (result.issues.length === 0)
11631
- return result;
11632
- results.push(result);
11644
+ if (result2.issues.length === 0)
11645
+ return result2;
11646
+ results.push(result2);
11633
11647
  }
11634
11648
  }
11635
11649
  if (!async)
@@ -11763,21 +11777,21 @@ function mergeValues(a, b2) {
11763
11777
  }
11764
11778
  return { valid: false, mergeErrorPath: [] };
11765
11779
  }
11766
- function handleIntersectionResults(result, left, right) {
11780
+ function handleIntersectionResults(result2, left, right) {
11767
11781
  if (left.issues.length) {
11768
- result.issues.push(...left.issues);
11782
+ result2.issues.push(...left.issues);
11769
11783
  }
11770
11784
  if (right.issues.length) {
11771
- result.issues.push(...right.issues);
11785
+ result2.issues.push(...right.issues);
11772
11786
  }
11773
- if (aborted(result))
11774
- return result;
11787
+ if (aborted(result2))
11788
+ return result2;
11775
11789
  const merged = mergeValues(left.value, right.value);
11776
11790
  if (!merged.valid) {
11777
11791
  throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
11778
11792
  }
11779
- result.value = merged.data;
11780
- return result;
11793
+ result2.value = merged.data;
11794
+ return result2;
11781
11795
  }
11782
11796
  var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
11783
11797
  $ZodType.init(inst, def);
@@ -11816,28 +11830,28 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
11816
11830
  if (i >= optStart)
11817
11831
  continue;
11818
11832
  }
11819
- const result = item._zod.run({
11833
+ const result2 = item._zod.run({
11820
11834
  value: input[i],
11821
11835
  issues: []
11822
11836
  }, ctx);
11823
- if (result instanceof Promise) {
11824
- proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
11837
+ if (result2 instanceof Promise) {
11838
+ proms.push(result2.then((result3) => handleTupleResult(result3, payload, i)));
11825
11839
  } else {
11826
- handleTupleResult(result, payload, i);
11840
+ handleTupleResult(result2, payload, i);
11827
11841
  }
11828
11842
  }
11829
11843
  if (def.rest) {
11830
11844
  const rest = input.slice(items.length);
11831
11845
  for (const el of rest) {
11832
11846
  i++;
11833
- const result = def.rest._zod.run({
11847
+ const result2 = def.rest._zod.run({
11834
11848
  value: el,
11835
11849
  issues: []
11836
11850
  }, ctx);
11837
- if (result instanceof Promise) {
11838
- proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
11851
+ if (result2 instanceof Promise) {
11852
+ proms.push(result2.then((result3) => handleTupleResult(result3, payload, i)));
11839
11853
  } else {
11840
- handleTupleResult(result, payload, i);
11854
+ handleTupleResult(result2, payload, i);
11841
11855
  }
11842
11856
  }
11843
11857
  }
@@ -11846,11 +11860,11 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
11846
11860
  return payload;
11847
11861
  };
11848
11862
  });
11849
- function handleTupleResult(result, final, index) {
11850
- if (result.issues.length) {
11851
- final.issues.push(...prefixIssues(index, result.issues));
11863
+ function handleTupleResult(result2, final, index) {
11864
+ if (result2.issues.length) {
11865
+ final.issues.push(...prefixIssues(index, result2.issues));
11852
11866
  }
11853
- final.value[index] = result.value;
11867
+ final.value[index] = result2.value;
11854
11868
  }
11855
11869
  var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
11856
11870
  $ZodType.init(inst, def);
@@ -11871,19 +11885,19 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
11871
11885
  payload.value = {};
11872
11886
  for (const key of values) {
11873
11887
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
11874
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
11875
- if (result instanceof Promise) {
11876
- proms.push(result.then((result2) => {
11877
- if (result2.issues.length) {
11878
- payload.issues.push(...prefixIssues(key, result2.issues));
11888
+ const result2 = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
11889
+ if (result2 instanceof Promise) {
11890
+ proms.push(result2.then((result3) => {
11891
+ if (result3.issues.length) {
11892
+ payload.issues.push(...prefixIssues(key, result3.issues));
11879
11893
  }
11880
- payload.value[key] = result2.value;
11894
+ payload.value[key] = result3.value;
11881
11895
  }));
11882
11896
  } else {
11883
- if (result.issues.length) {
11884
- payload.issues.push(...prefixIssues(key, result.issues));
11897
+ if (result2.issues.length) {
11898
+ payload.issues.push(...prefixIssues(key, result2.issues));
11885
11899
  }
11886
- payload.value[key] = result.value;
11900
+ payload.value[key] = result2.value;
11887
11901
  }
11888
11902
  }
11889
11903
  }
@@ -11923,19 +11937,19 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
11923
11937
  payload.value[keyResult.value] = keyResult.value;
11924
11938
  continue;
11925
11939
  }
11926
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
11927
- if (result instanceof Promise) {
11928
- proms.push(result.then((result2) => {
11929
- if (result2.issues.length) {
11930
- payload.issues.push(...prefixIssues(key, result2.issues));
11940
+ const result2 = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
11941
+ if (result2 instanceof Promise) {
11942
+ proms.push(result2.then((result3) => {
11943
+ if (result3.issues.length) {
11944
+ payload.issues.push(...prefixIssues(key, result3.issues));
11931
11945
  }
11932
- payload.value[keyResult.value] = result2.value;
11946
+ payload.value[keyResult.value] = result3.value;
11933
11947
  }));
11934
11948
  } else {
11935
- if (result.issues.length) {
11936
- payload.issues.push(...prefixIssues(key, result.issues));
11949
+ if (result2.issues.length) {
11950
+ payload.issues.push(...prefixIssues(key, result2.issues));
11937
11951
  }
11938
- payload.value[keyResult.value] = result.value;
11952
+ payload.value[keyResult.value] = result2.value;
11939
11953
  }
11940
11954
  }
11941
11955
  }
@@ -12022,22 +12036,22 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
12022
12036
  const proms = [];
12023
12037
  payload.value = /* @__PURE__ */ new Set();
12024
12038
  for (const item of input) {
12025
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
12026
- if (result instanceof Promise) {
12027
- proms.push(result.then((result2) => handleSetResult(result2, payload)));
12039
+ const result2 = def.valueType._zod.run({ value: item, issues: [] }, ctx);
12040
+ if (result2 instanceof Promise) {
12041
+ proms.push(result2.then((result3) => handleSetResult(result3, payload)));
12028
12042
  } else
12029
- handleSetResult(result, payload);
12043
+ handleSetResult(result2, payload);
12030
12044
  }
12031
12045
  if (proms.length)
12032
12046
  return Promise.all(proms).then(() => payload);
12033
12047
  return payload;
12034
12048
  };
12035
12049
  });
12036
- function handleSetResult(result, final) {
12037
- if (result.issues.length) {
12038
- final.issues.push(...result.issues);
12050
+ function handleSetResult(result2, final) {
12051
+ if (result2.issues.length) {
12052
+ final.issues.push(...result2.issues);
12039
12053
  }
12040
- final.value.add(result.value);
12054
+ final.value.add(result2.value);
12041
12055
  }
12042
12056
  var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
12043
12057
  $ZodType.init(inst, def);
@@ -12116,11 +12130,11 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
12116
12130
  return payload;
12117
12131
  };
12118
12132
  });
12119
- function handleOptionalResult(result, input) {
12120
- if (result.issues.length && input === void 0) {
12133
+ function handleOptionalResult(result2, input) {
12134
+ if (result2.issues.length && input === void 0) {
12121
12135
  return { issues: [], value: void 0 };
12122
12136
  }
12123
- return result;
12137
+ return result2;
12124
12138
  }
12125
12139
  var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
12126
12140
  $ZodType.init(inst, def);
@@ -12135,10 +12149,10 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
12135
12149
  });
12136
12150
  inst._zod.parse = (payload, ctx) => {
12137
12151
  if (def.innerType._zod.optin === "optional") {
12138
- const result = def.innerType._zod.run(payload, ctx);
12139
- if (result instanceof Promise)
12140
- return result.then((r) => handleOptionalResult(r, payload.value));
12141
- return handleOptionalResult(result, payload.value);
12152
+ const result2 = def.innerType._zod.run(payload, ctx);
12153
+ if (result2 instanceof Promise)
12154
+ return result2.then((r) => handleOptionalResult(r, payload.value));
12155
+ return handleOptionalResult(result2, payload.value);
12142
12156
  }
12143
12157
  if (payload.value === void 0) {
12144
12158
  return payload;
@@ -12175,11 +12189,11 @@ var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
12175
12189
  payload.value = def.defaultValue;
12176
12190
  return payload;
12177
12191
  }
12178
- const result = def.innerType._zod.run(payload, ctx);
12179
- if (result instanceof Promise) {
12180
- return result.then((result2) => handleDefaultResult(result2, def));
12192
+ const result2 = def.innerType._zod.run(payload, ctx);
12193
+ if (result2 instanceof Promise) {
12194
+ return result2.then((result3) => handleDefaultResult(result3, def));
12181
12195
  }
12182
- return handleDefaultResult(result, def);
12196
+ return handleDefaultResult(result2, def);
12183
12197
  };
12184
12198
  });
12185
12199
  function handleDefaultResult(payload, def) {
@@ -12209,11 +12223,11 @@ var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def
12209
12223
  return v2 ? new Set([...v2].filter((x) => x !== void 0)) : void 0;
12210
12224
  });
12211
12225
  inst._zod.parse = (payload, ctx) => {
12212
- const result = def.innerType._zod.run(payload, ctx);
12213
- if (result instanceof Promise) {
12214
- return result.then((result2) => handleNonOptionalResult(result2, inst));
12226
+ const result2 = def.innerType._zod.run(payload, ctx);
12227
+ if (result2 instanceof Promise) {
12228
+ return result2.then((result3) => handleNonOptionalResult(result3, inst));
12215
12229
  }
12216
- return handleNonOptionalResult(result, inst);
12230
+ return handleNonOptionalResult(result2, inst);
12217
12231
  };
12218
12232
  });
12219
12233
  function handleNonOptionalResult(payload, inst) {
@@ -12233,14 +12247,14 @@ var $ZodSuccess = /* @__PURE__ */ $constructor("$ZodSuccess", (inst, def) => {
12233
12247
  if (ctx.direction === "backward") {
12234
12248
  throw new $ZodEncodeError("ZodSuccess");
12235
12249
  }
12236
- const result = def.innerType._zod.run(payload, ctx);
12237
- if (result instanceof Promise) {
12238
- return result.then((result2) => {
12239
- payload.value = result2.issues.length === 0;
12250
+ const result2 = def.innerType._zod.run(payload, ctx);
12251
+ if (result2 instanceof Promise) {
12252
+ return result2.then((result3) => {
12253
+ payload.value = result3.issues.length === 0;
12240
12254
  return payload;
12241
12255
  });
12242
12256
  }
12243
- payload.value = result.issues.length === 0;
12257
+ payload.value = result2.issues.length === 0;
12244
12258
  return payload;
12245
12259
  };
12246
12260
  });
@@ -12253,15 +12267,15 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
12253
12267
  if (ctx.direction === "backward") {
12254
12268
  return def.innerType._zod.run(payload, ctx);
12255
12269
  }
12256
- const result = def.innerType._zod.run(payload, ctx);
12257
- if (result instanceof Promise) {
12258
- return result.then((result2) => {
12259
- payload.value = result2.value;
12260
- if (result2.issues.length) {
12270
+ const result2 = def.innerType._zod.run(payload, ctx);
12271
+ if (result2 instanceof Promise) {
12272
+ return result2.then((result3) => {
12273
+ payload.value = result3.value;
12274
+ if (result3.issues.length) {
12261
12275
  payload.value = def.catchValue({
12262
12276
  ...payload,
12263
12277
  error: {
12264
- issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
12278
+ issues: result3.issues.map((iss) => finalizeIssue(iss, ctx, config()))
12265
12279
  },
12266
12280
  input: payload.value
12267
12281
  });
@@ -12270,12 +12284,12 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
12270
12284
  return payload;
12271
12285
  });
12272
12286
  }
12273
- payload.value = result.value;
12274
- if (result.issues.length) {
12287
+ payload.value = result2.value;
12288
+ if (result2.issues.length) {
12275
12289
  payload.value = def.catchValue({
12276
12290
  ...payload,
12277
12291
  error: {
12278
- issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
12292
+ issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
12279
12293
  },
12280
12294
  input: payload.value
12281
12295
  });
@@ -12350,24 +12364,24 @@ var $ZodCodec = /* @__PURE__ */ $constructor("$ZodCodec", (inst, def) => {
12350
12364
  }
12351
12365
  };
12352
12366
  });
12353
- function handleCodecAResult(result, def, ctx) {
12354
- if (result.issues.length) {
12355
- result.aborted = true;
12356
- return result;
12367
+ function handleCodecAResult(result2, def, ctx) {
12368
+ if (result2.issues.length) {
12369
+ result2.aborted = true;
12370
+ return result2;
12357
12371
  }
12358
12372
  const direction = ctx.direction || "forward";
12359
12373
  if (direction === "forward") {
12360
- const transformed = def.transform(result.value, result);
12374
+ const transformed = def.transform(result2.value, result2);
12361
12375
  if (transformed instanceof Promise) {
12362
- return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
12376
+ return transformed.then((value) => handleCodecTxResult(result2, value, def.out, ctx));
12363
12377
  }
12364
- return handleCodecTxResult(result, transformed, def.out, ctx);
12378
+ return handleCodecTxResult(result2, transformed, def.out, ctx);
12365
12379
  } else {
12366
- const transformed = def.reverseTransform(result.value, result);
12380
+ const transformed = def.reverseTransform(result2.value, result2);
12367
12381
  if (transformed instanceof Promise) {
12368
- return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
12382
+ return transformed.then((value) => handleCodecTxResult(result2, value, def.in, ctx));
12369
12383
  }
12370
- return handleCodecTxResult(result, transformed, def.in, ctx);
12384
+ return handleCodecTxResult(result2, transformed, def.in, ctx);
12371
12385
  }
12372
12386
  }
12373
12387
  function handleCodecTxResult(left, value, nextSchema, ctx) {
@@ -12387,11 +12401,11 @@ var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
12387
12401
  if (ctx.direction === "backward") {
12388
12402
  return def.innerType._zod.run(payload, ctx);
12389
12403
  }
12390
- const result = def.innerType._zod.run(payload, ctx);
12391
- if (result instanceof Promise) {
12392
- return result.then(handleReadonlyResult);
12404
+ const result2 = def.innerType._zod.run(payload, ctx);
12405
+ if (result2 instanceof Promise) {
12406
+ return result2.then(handleReadonlyResult);
12393
12407
  }
12394
- return handleReadonlyResult(result);
12408
+ return handleReadonlyResult(result2);
12395
12409
  };
12396
12410
  });
12397
12411
  function handleReadonlyResult(payload) {
@@ -12453,11 +12467,11 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
12453
12467
  }
12454
12468
  return function(...args) {
12455
12469
  const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
12456
- const result = Reflect.apply(func, this, parsedArgs);
12470
+ const result2 = Reflect.apply(func, this, parsedArgs);
12457
12471
  if (inst._def.output) {
12458
- return parse(inst._def.output, result);
12472
+ return parse(inst._def.output, result2);
12459
12473
  }
12460
- return result;
12474
+ return result2;
12461
12475
  };
12462
12476
  };
12463
12477
  inst.implementAsync = (func) => {
@@ -12466,11 +12480,11 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
12466
12480
  }
12467
12481
  return async function(...args) {
12468
12482
  const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
12469
- const result = await Reflect.apply(func, this, parsedArgs);
12483
+ const result2 = await Reflect.apply(func, this, parsedArgs);
12470
12484
  if (inst._def.output) {
12471
- return await parseAsync(inst._def.output, result);
12485
+ return await parseAsync(inst._def.output, result2);
12472
12486
  }
12473
- return result;
12487
+ return result2;
12474
12488
  };
12475
12489
  };
12476
12490
  inst._zod.parse = (payload, _ctx) => {
@@ -12554,8 +12568,8 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
12554
12568
  return;
12555
12569
  };
12556
12570
  });
12557
- function handleRefineResult(result, payload, input, inst) {
12558
- if (!result) {
12571
+ function handleRefineResult(result2, payload, input, inst) {
12572
+ if (!result2) {
12559
12573
  const _iss = {
12560
12574
  code: "custom",
12561
12575
  input,
@@ -15601,12 +15615,12 @@ var error24 = () => {
15601
15615
  }
15602
15616
  };
15603
15617
  function getSizing(origin, unitType, inclusive, targetShouldBe) {
15604
- const result = Sizable[origin] ?? null;
15605
- if (result === null)
15606
- return result;
15618
+ const result2 = Sizable[origin] ?? null;
15619
+ if (result2 === null)
15620
+ return result2;
15607
15621
  return {
15608
- unit: result.unit[unitType],
15609
- verb: result.verb[targetShouldBe][inclusive ? "inclusive" : "notInclusive"]
15622
+ unit: result2.unit[unitType],
15623
+ verb: result2.verb[targetShouldBe][inclusive ? "inclusive" : "notInclusive"]
15610
15624
  };
15611
15625
  }
15612
15626
  const Nouns = {
@@ -19074,11 +19088,11 @@ var JSONSchemaGenerator = class {
19074
19088
  }
19075
19089
  return seen.schema;
19076
19090
  }
19077
- const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
19078
- this.seen.set(schema, result);
19091
+ const result2 = { schema: {}, count: 1, cycle: void 0, path: _params.path };
19092
+ this.seen.set(schema, result2);
19079
19093
  const overrideSchema = schema._zod.toJSONSchema?.();
19080
19094
  if (overrideSchema) {
19081
- result.schema = overrideSchema;
19095
+ result2.schema = overrideSchema;
19082
19096
  } else {
19083
19097
  const params = {
19084
19098
  ..._params,
@@ -19087,11 +19101,11 @@ var JSONSchemaGenerator = class {
19087
19101
  };
19088
19102
  const parent = schema._zod.parent;
19089
19103
  if (parent) {
19090
- result.ref = parent;
19104
+ result2.ref = parent;
19091
19105
  this.process(parent, params);
19092
19106
  this.seen.get(parent).isParent = true;
19093
19107
  } else {
19094
- const _json = result.schema;
19108
+ const _json = result2.schema;
19095
19109
  switch (def.type) {
19096
19110
  case "string": {
19097
19111
  const json2 = _json;
@@ -19113,7 +19127,7 @@ var JSONSchemaGenerator = class {
19113
19127
  if (regexes.length === 1)
19114
19128
  json2.pattern = regexes[0].source;
19115
19129
  else if (regexes.length > 1) {
19116
- result.schema.allOf = [
19130
+ result2.schema.allOf = [
19117
19131
  ...regexes.map((regex) => ({
19118
19132
  ...this.target === "draft-7" || this.target === "draft-4" || this.target === "openapi-3.0" ? { type: "string" } : {},
19119
19133
  pattern: regex.source
@@ -19452,7 +19466,7 @@ var JSONSchemaGenerator = class {
19452
19466
  case "nullable": {
19453
19467
  const inner = this.process(def.innerType, params);
19454
19468
  if (this.target === "openapi-3.0") {
19455
- result.ref = def.innerType;
19469
+ result2.ref = def.innerType;
19456
19470
  _json.nullable = true;
19457
19471
  } else {
19458
19472
  _json.anyOf = [inner, { type: "null" }];
@@ -19461,7 +19475,7 @@ var JSONSchemaGenerator = class {
19461
19475
  }
19462
19476
  case "nonoptional": {
19463
19477
  this.process(def.innerType, params);
19464
- result.ref = def.innerType;
19478
+ result2.ref = def.innerType;
19465
19479
  break;
19466
19480
  }
19467
19481
  case "success": {
@@ -19471,20 +19485,20 @@ var JSONSchemaGenerator = class {
19471
19485
  }
19472
19486
  case "default": {
19473
19487
  this.process(def.innerType, params);
19474
- result.ref = def.innerType;
19488
+ result2.ref = def.innerType;
19475
19489
  _json.default = JSON.parse(JSON.stringify(def.defaultValue));
19476
19490
  break;
19477
19491
  }
19478
19492
  case "prefault": {
19479
19493
  this.process(def.innerType, params);
19480
- result.ref = def.innerType;
19494
+ result2.ref = def.innerType;
19481
19495
  if (this.io === "input")
19482
19496
  _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
19483
19497
  break;
19484
19498
  }
19485
19499
  case "catch": {
19486
19500
  this.process(def.innerType, params);
19487
- result.ref = def.innerType;
19501
+ result2.ref = def.innerType;
19488
19502
  let catchValue;
19489
19503
  try {
19490
19504
  catchValue = def.catchValue(void 0);
@@ -19512,30 +19526,30 @@ var JSONSchemaGenerator = class {
19512
19526
  case "pipe": {
19513
19527
  const innerType = this.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
19514
19528
  this.process(innerType, params);
19515
- result.ref = innerType;
19529
+ result2.ref = innerType;
19516
19530
  break;
19517
19531
  }
19518
19532
  case "readonly": {
19519
19533
  this.process(def.innerType, params);
19520
- result.ref = def.innerType;
19534
+ result2.ref = def.innerType;
19521
19535
  _json.readOnly = true;
19522
19536
  break;
19523
19537
  }
19524
19538
  // passthrough types
19525
19539
  case "promise": {
19526
19540
  this.process(def.innerType, params);
19527
- result.ref = def.innerType;
19541
+ result2.ref = def.innerType;
19528
19542
  break;
19529
19543
  }
19530
19544
  case "optional": {
19531
19545
  this.process(def.innerType, params);
19532
- result.ref = def.innerType;
19546
+ result2.ref = def.innerType;
19533
19547
  break;
19534
19548
  }
19535
19549
  case "lazy": {
19536
19550
  const innerType = schema._zod.innerType;
19537
19551
  this.process(innerType, params);
19538
- result.ref = innerType;
19552
+ result2.ref = innerType;
19539
19553
  break;
19540
19554
  }
19541
19555
  case "custom": {
@@ -19558,14 +19572,14 @@ var JSONSchemaGenerator = class {
19558
19572
  }
19559
19573
  const meta = this.metadataRegistry.get(schema);
19560
19574
  if (meta)
19561
- Object.assign(result.schema, meta);
19575
+ Object.assign(result2.schema, meta);
19562
19576
  if (this.io === "input" && isTransforming(schema)) {
19563
- delete result.schema.examples;
19564
- delete result.schema.default;
19577
+ delete result2.schema.examples;
19578
+ delete result2.schema.default;
19565
19579
  }
19566
- if (this.io === "input" && result.schema._prefault)
19567
- (_a = result.schema).default ?? (_a.default = result.schema._prefault);
19568
- delete result.schema._prefault;
19580
+ if (this.io === "input" && result2.schema._prefault)
19581
+ (_a = result2.schema).default ?? (_a.default = result2.schema._prefault);
19582
+ delete result2.schema._prefault;
19569
19583
  const _result = this.seen.get(schema);
19570
19584
  return _result.schema;
19571
19585
  }
@@ -19684,13 +19698,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19684
19698
  for (const entry of [...this.seen.entries()].reverse()) {
19685
19699
  flattenRef(entry[0], { target: this.target });
19686
19700
  }
19687
- const result = {};
19701
+ const result2 = {};
19688
19702
  if (this.target === "draft-2020-12") {
19689
- result.$schema = "https://json-schema.org/draft/2020-12/schema";
19703
+ result2.$schema = "https://json-schema.org/draft/2020-12/schema";
19690
19704
  } else if (this.target === "draft-7") {
19691
- result.$schema = "http://json-schema.org/draft-07/schema#";
19705
+ result2.$schema = "http://json-schema.org/draft-07/schema#";
19692
19706
  } else if (this.target === "draft-4") {
19693
- result.$schema = "http://json-schema.org/draft-04/schema#";
19707
+ result2.$schema = "http://json-schema.org/draft-04/schema#";
19694
19708
  } else if (this.target === "openapi-3.0") {
19695
19709
  } else {
19696
19710
  console.warn(`Invalid target: ${this.target}`);
@@ -19699,9 +19713,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19699
19713
  const id = params.external.registry.get(schema)?.id;
19700
19714
  if (!id)
19701
19715
  throw new Error("Schema is missing an `id` property");
19702
- result.$id = params.external.uri(id);
19716
+ result2.$id = params.external.uri(id);
19703
19717
  }
19704
- Object.assign(result, root.def);
19718
+ Object.assign(result2, root.def);
19705
19719
  const defs = params.external?.defs ?? {};
19706
19720
  for (const entry of this.seen.entries()) {
19707
19721
  const seen = entry[1];
@@ -19713,14 +19727,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19713
19727
  } else {
19714
19728
  if (Object.keys(defs).length > 0) {
19715
19729
  if (this.target === "draft-2020-12") {
19716
- result.$defs = defs;
19730
+ result2.$defs = defs;
19717
19731
  } else {
19718
- result.definitions = defs;
19732
+ result2.definitions = defs;
19719
19733
  }
19720
19734
  }
19721
19735
  }
19722
19736
  try {
19723
- return JSON.parse(JSON.stringify(result));
19737
+ return JSON.parse(JSON.stringify(result2));
19724
19738
  } catch (_err) {
19725
19739
  throw new Error("Error converting schema to JSON.");
19726
19740
  }
@@ -21003,7 +21017,7 @@ tool.schema = external_exports;
21003
21017
 
21004
21018
  // packages/cli/src/opencode2Adapter.ts
21005
21019
  var z = tool.schema;
21006
- function openCode2Tool(name, definition, directoryOf) {
21020
+ function openCode2Tool(name, definition, directoryOf, permission) {
21007
21021
  const schema = z.object(definition.args);
21008
21022
  return {
21009
21023
  name,
@@ -21020,8 +21034,22 @@ ${issues.join("\n")}
21020
21034
  Update the arguments and call the tool again.`);
21021
21035
  }
21022
21036
  const directory = await directoryOf(context.sessionID);
21023
- const result = await definition.execute(parsed.data, { directory, abort: context.signal });
21024
- return openCode2Result(result);
21037
+ const ask = async (request) => {
21038
+ context.signal.throwIfAborted();
21039
+ if (!permission?.assert) throw new Error("Este motor n\xE3o suporta a aprova\xE7\xE3o do envio. Atualize o OpenWork ou copie o relat\xF3rio.");
21040
+ await permission.assert({
21041
+ sessionID: context.sessionID,
21042
+ ...context.agent ? { agent: context.agent } : {},
21043
+ action: request.permission,
21044
+ resources: request.patterns,
21045
+ save: [],
21046
+ metadata: request.metadata,
21047
+ ...context.messageID && context.id ? { source: { type: "tool", messageID: context.messageID, id: context.id } } : {}
21048
+ });
21049
+ context.signal.throwIfAborted();
21050
+ };
21051
+ const result2 = await definition.execute(parsed.data, { directory, abort: context.signal, ask });
21052
+ return openCode2Result(result2);
21025
21053
  }
21026
21054
  };
21027
21055
  }
@@ -21035,17 +21063,17 @@ function sessionDirectoryResolver(ctx) {
21035
21063
  return ctx.location.directory;
21036
21064
  };
21037
21065
  }
21038
- function openCode2Result(result) {
21039
- if (typeof result === "string") return { content: result };
21040
- const files = (result.attachments ?? []).map((attachment) => ({
21066
+ function openCode2Result(result2) {
21067
+ if (typeof result2 === "string") return { content: result2 };
21068
+ const files = (result2.attachments ?? []).map((attachment) => ({
21041
21069
  type: "file",
21042
21070
  uri: attachment.url,
21043
21071
  mime: attachment.mime,
21044
21072
  ...attachment.filename ? { name: attachment.filename } : {}
21045
21073
  }));
21046
21074
  return {
21047
- content: files.length > 0 ? [{ type: "text", text: result.output }, ...files] : result.output,
21048
- ...result.metadata ? { metadata: result.metadata } : {}
21075
+ content: files.length > 0 ? [{ type: "text", text: result2.output }, ...files] : result2.output,
21076
+ ...result2.metadata ? { metadata: result2.metadata } : {}
21049
21077
  };
21050
21078
  }
21051
21079
  function completedSkillCall(event) {
@@ -21087,9 +21115,9 @@ function guardEventsFor(event) {
21087
21115
  function openCode2GuardClient(ctx) {
21088
21116
  return {
21089
21117
  session: {
21090
- abort: ({ path: path16 }) => ctx.session.interrupt({ sessionID: path16.id }),
21118
+ abort: ({ path: path18 }) => ctx.session.interrupt({ sessionID: path18.id }),
21091
21119
  // The resume prompt runs with the session's current agent and model, so `body.agent` and `body.model` are not sent.
21092
- promptAsync: ({ path: path16, body }) => ctx.session.prompt({ sessionID: path16.id, text: body.parts.map((part) => part.text).join("\n\n") })
21120
+ promptAsync: ({ path: path18, body }) => ctx.session.prompt({ sessionID: path18.id, text: body.parts.map((part) => part.text).join("\n\n") })
21093
21121
  }
21094
21122
  };
21095
21123
  }
@@ -21140,9 +21168,9 @@ function isRecord2(value) {
21140
21168
  }
21141
21169
 
21142
21170
  // packages/cli/src/workPackSyncPlugin.ts
21143
- import { link, mkdir as mkdir8, mkdtemp as mkdtemp2, readdir as readdir8, readFile as readFile15, realpath as realpath3, rename as rename9, rm as rm6, rmdir as rmdir2, stat as stat3, unlink as unlink2, writeFile as writeFile9 } from "node:fs/promises";
21144
- import os5 from "node:os";
21145
- import path15 from "node:path";
21171
+ import { link, mkdir as mkdir8, mkdtemp as mkdtemp2, readdir as readdir8, readFile as readFile16, realpath as realpath3, rename as rename9, rm as rm6, rmdir as rmdir2, stat as stat4, unlink as unlink2, writeFile as writeFile9 } from "node:fs/promises";
21172
+ import os6 from "node:os";
21173
+ import path17 from "node:path";
21146
21174
 
21147
21175
  // packages/cli/src/credentials.ts
21148
21176
  import { chmod as chmod2, mkdir as mkdir2, readFile as readFile3, rename as rename3, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
@@ -21282,7 +21310,7 @@ async function adoptWorkPackInstalledState(input) {
21282
21310
  const state = await readInstalledState(input.expectedPackDir);
21283
21311
  if (!state || !await matchesInstalledState(input, state)) return false;
21284
21312
  await writeJsonAtomic(path5.join(input.packDir, WORK_PACK_LOCAL_STATE_FILENAME), state);
21285
- return checkWorkPackInstalledState(input).then((result) => result === "match");
21313
+ return checkWorkPackInstalledState(input).then((result2) => result2 === "match");
21286
21314
  }
21287
21315
  async function readInstalledState(packDir) {
21288
21316
  const info = await lstat2(path5.join(packDir, WORK_PACK_LOCAL_STATE_FILENAME)).catch(() => void 0);
@@ -21394,23 +21422,23 @@ function emptySummary() {
21394
21422
  async function inspectWorkPackIntegrity(input) {
21395
21423
  assertSlug(input.slug);
21396
21424
  const packDir = path6.join(input.paths.skillsDir, input.slug);
21397
- const result = { slug: input.slug, summary: emptySummary(), differences: [], differencesTruncated: false };
21425
+ const result2 = { slug: input.slug, summary: emptySummary(), differences: [], differencesTruncated: false };
21398
21426
  const add = (kind, area, name) => {
21399
- if (result.summary[kind] === MAX_ENTRIES) result.summary.truncated = true;
21400
- result.summary[kind] = Math.min(MAX_ENTRIES, result.summary[kind] + 1);
21401
- if (result.differences.length < MAX_DIFFERENCES) result.differences.push({ kind, area, path: name });
21402
- else result.differencesTruncated = true;
21427
+ if (result2.summary[kind] === MAX_ENTRIES) result2.summary.truncated = true;
21428
+ result2.summary[kind] = Math.min(MAX_ENTRIES, result2.summary[kind] + 1);
21429
+ if (result2.differences.length < MAX_DIFFERENCES) result2.differences.push({ kind, area, path: name });
21430
+ else result2.differencesTruncated = true;
21403
21431
  };
21404
21432
  const root = await lstat3(packDir).catch(() => void 0);
21405
21433
  if (!root?.isDirectory() || root.isSymbolicLink()) {
21406
21434
  add(root ? "unsafe" : "unreadable", "pack", ".");
21407
- result.summary.kind = "unsafe-or-unreadable";
21408
- return result;
21435
+ result2.summary.kind = "unsafe-or-unreadable";
21436
+ return result2;
21409
21437
  }
21410
21438
  const expected = input.expected ? parseWorkPackFileManifest(input.expected) : await readInstalledState(packDir);
21411
- if (!expected) return result;
21412
- result.version = expected.version;
21413
- result.summary.reference = input.expected ? input.reference ?? "server" : "installation-receipt";
21439
+ if (!expected) return result2;
21440
+ result2.version = expected.version;
21441
+ result2.summary.reference = input.expected ? input.reference ?? "server" : "installation-receipt";
21414
21442
  const readBudget = { remaining: 128 * 1024 * 1024, exceeded: false };
21415
21443
  const original = new Map(expected.files.map((file2) => [file2.path, file2.sha256]));
21416
21444
  const directories = new Set(expected.directories);
@@ -21418,7 +21446,7 @@ async function inspectWorkPackIntegrity(input) {
21418
21446
  const extraFiles = [], extraDirectories = [], blocked = [];
21419
21447
  let entries = 0;
21420
21448
  const walk = async (directory, prefix) => {
21421
- if (result.summary.truncated) return;
21449
+ if (result2.summary.truncated) return;
21422
21450
  let children;
21423
21451
  try {
21424
21452
  children = await readdir3(directory, { withFileTypes: true });
@@ -21429,7 +21457,7 @@ async function inspectWorkPackIntegrity(input) {
21429
21457
  }
21430
21458
  for (const entry of children.sort((a, b2) => a.name < b2.name ? -1 : a.name > b2.name ? 1 : 0)) {
21431
21459
  if (++entries > MAX_ENTRIES) {
21432
- result.summary.truncated = true;
21460
+ result2.summary.truncated = true;
21433
21461
  return;
21434
21462
  }
21435
21463
  const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
@@ -21474,7 +21502,7 @@ async function inspectWorkPackIntegrity(input) {
21474
21502
  }
21475
21503
  };
21476
21504
  await walk(packDir, "");
21477
- const inaccessible = (name) => result.summary.truncated || blocked.some((parent) => !parent || name === parent || name.startsWith(`${parent}/`));
21505
+ const inaccessible = (name) => result2.summary.truncated || blocked.some((parent) => !parent || name === parent || name.startsWith(`${parent}/`));
21478
21506
  for (const name of original.keys()) if (!seenFiles.has(name) && !seenDirectories.has(name) && !inaccessible(name)) add("missing", "pack", name);
21479
21507
  for (const name of directories) if (!seenDirectories.has(name) && !seenFiles.has(name) && !inaccessible(name)) add("missing", "pack", name);
21480
21508
  const cacheDirectories = /* @__PURE__ */ new Set();
@@ -21511,9 +21539,9 @@ async function inspectWorkPackIntegrity(input) {
21511
21539
  }
21512
21540
  }
21513
21541
  }
21514
- result.summary.truncated ||= readBudget.exceeded;
21515
- result.summary.kind = integrityKind(result.summary);
21516
- return result;
21542
+ result2.summary.truncated ||= readBudget.exceeded;
21543
+ result2.summary.kind = integrityKind(result2.summary);
21544
+ return result2;
21517
21545
  }
21518
21546
  async function regularFileDigest(filePath, budget) {
21519
21547
  try {
@@ -25260,30 +25288,30 @@ function omittedProjectionOwners(omitted, conflict) {
25260
25288
  return omitted.filter((pack) => pack[field]?.includes(conflict.filename));
25261
25289
  }
25262
25290
  async function runOperation(operation, operate) {
25263
- let result;
25291
+ let result2;
25264
25292
  try {
25265
- result = await operate(operation);
25293
+ result2 = await operate(operation);
25266
25294
  } catch {
25267
25295
  return uncertainOutcome(operation, "callback-threw");
25268
25296
  }
25269
- if (result.status === "recovery-uncertain") return uncertainOutcome(operation, stableCode(result.code));
25270
- if (result.status === "failed") {
25297
+ if (result2.status === "recovery-uncertain") return uncertainOutcome(operation, stableCode(result2.code));
25298
+ if (result2.status === "failed") {
25271
25299
  return {
25272
25300
  ...outcomeIdentity(operation),
25273
25301
  status: "failed",
25274
- code: stableCode(result.code),
25275
- ...result.integrity ? { integrity: result.integrity } : {},
25276
- ...result.projectionConflict ? { projectionConflict: result.projectionConflict } : {},
25277
- message: result.message ?? `O pacote "${operation.pack.slug}" falhou, mas o estado anterior foi restaurado exatamente. Corrija a causa indicada e volte a sincronizar.`
25302
+ code: stableCode(result2.code),
25303
+ ...result2.integrity ? { integrity: result2.integrity } : {},
25304
+ ...result2.projectionConflict ? { projectionConflict: result2.projectionConflict } : {},
25305
+ message: result2.message ?? `O pacote "${operation.pack.slug}" falhou, mas o estado anterior foi restaurado exatamente. Corrija a causa indicada e volte a sincronizar.`
25278
25306
  };
25279
25307
  }
25280
- if (!validSuccessFor(operation.action, result.status)) return uncertainOutcome(operation, "invalid-callback-result");
25308
+ if (!validSuccessFor(operation.action, result2.status)) return uncertainOutcome(operation, "invalid-callback-result");
25281
25309
  return {
25282
25310
  ...outcomeIdentity(operation),
25283
- status: result.status,
25284
- ...result.warningCode ? { warningCode: stableCode(result.warningCode) } : {},
25285
- ...result.message ? { message: result.message } : {},
25286
- ...result.removedManagedPaths ? { removedManagedPaths: [...new Set(result.removedManagedPaths)].sort() } : {}
25311
+ status: result2.status,
25312
+ ...result2.warningCode ? { warningCode: stableCode(result2.warningCode) } : {},
25313
+ ...result2.message ? { message: result2.message } : {},
25314
+ ...result2.removedManagedPaths ? { removedManagedPaths: [...new Set(result2.removedManagedPaths)].sort() } : {}
25287
25315
  };
25288
25316
  }
25289
25317
  function uncertainOutcome(operation, code) {
@@ -25549,15 +25577,15 @@ async function collectWorkPackObservations(paths, reconciliation) {
25549
25577
  }
25550
25578
  return [...observations.values()].sort((a, b2) => a.slug.localeCompare(b2.slug));
25551
25579
  }
25552
- async function enrichIntegrityFailure(paths, operation, result) {
25553
- if (result.status !== "failed" || result.integrity || !["local-edits-preserved", "local-baseline-missing"].includes(result.code)) return result;
25580
+ async function enrichIntegrityFailure(paths, operation, result2) {
25581
+ if (result2.status !== "failed" || result2.integrity || !["local-edits-preserved", "local-baseline-missing"].includes(result2.code)) return result2;
25554
25582
  try {
25555
25583
  const { summary } = await inspectWorkPackIntegrity({ paths, slug: operation.pack.slug });
25556
- if (summary.kind === "match") return result;
25557
- const code = summary.kind === "runtime-artifacts" ? "local-runtime-artifacts" : summary.kind === "unknown-additions" ? "local-additions-preserved" : summary.kind === "unsafe-or-unreadable" ? "local-state-unreadable" : result.code;
25558
- return { ...result, code, integrity: summary };
25584
+ if (summary.kind === "match") return result2;
25585
+ const code = summary.kind === "runtime-artifacts" ? "local-runtime-artifacts" : summary.kind === "unknown-additions" ? "local-additions-preserved" : summary.kind === "unsafe-or-unreadable" ? "local-state-unreadable" : result2.code;
25586
+ return { ...result2, code, integrity: summary };
25559
25587
  } catch {
25560
- return result;
25588
+ return result2;
25561
25589
  }
25562
25590
  }
25563
25591
  async function operateWorkPack(paths, credentials, skillBySlug, approvedModelIds, cleanupPendingSlugs, recoveryFailures, operation, authoritative, options) {
@@ -26927,12 +26955,12 @@ function sha2562(value) {
26927
26955
 
26928
26956
  // packages/cli/src/localWorkerSync.ts
26929
26957
  async function syncLocalWorker(paths, credentials, manifest) {
26930
- const result = await applyManifest(paths, credentials, manifest, {
26958
+ const result2 = await applyManifest(paths, credentials, manifest, {
26931
26959
  beforeCore: () => prepareLocalStartup(paths, credentials),
26932
26960
  afterCore: () => removeWellKnownAuth(paths, credentials)
26933
26961
  });
26934
26962
  await recordRollbackEvidencePlugin(paths, renderEvidencePlugin());
26935
- return result;
26963
+ return result2;
26936
26964
  }
26937
26965
  async function prepareLocalStartup(paths, credentials) {
26938
26966
  let current;
@@ -27129,10 +27157,360 @@ async function resolveWritePath(file2) {
27129
27157
  }
27130
27158
  }
27131
27159
 
27160
+ // packages/cli/src/workPackPythonStartup.ts
27161
+ import { createHash as createHash9 } from "node:crypto";
27162
+ import { lstat as lstat8 } from "node:fs/promises";
27163
+ import path16 from "node:path";
27164
+
27165
+ // packages/cli/src/pythonReadiness.ts
27166
+ import { execFile } from "node:child_process";
27167
+ import { createHash as createHash8, randomUUID as randomUUID5 } from "node:crypto";
27168
+ import { readFile as readFile15, stat as stat3 } from "node:fs/promises";
27169
+ import os5 from "node:os";
27170
+ import path15 from "node:path";
27171
+ import { promisify } from "node:util";
27172
+ var runPython = promisify(execFile);
27173
+ var CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
27174
+ var PROBE_MARKER = "FORGE_PYTHON_READINESS=";
27175
+ var PROBE = String.raw`
27176
+ import sys
27177
+
27178
+ # The check runs against the interpreter's installed packages without importing
27179
+ # scripts from the directory in which OpenWork or the CLI was opened.
27180
+ if sys.path and sys.path[0] == "":
27181
+ sys.path.pop(0)
27182
+
27183
+ import json
27184
+ import os
27185
+ import platform
27186
+
27187
+ identity = {
27188
+ "interpreter": os.path.abspath(sys.executable) if sys.executable else "",
27189
+ "pythonVersion": platform.python_version(),
27190
+ "supported": sys.version_info >= (3, 10),
27191
+ }
27192
+ if not identity["supported"]:
27193
+ print("${PROBE_MARKER}" + json.dumps(identity))
27194
+ sys.exit(0)
27195
+
27196
+ import importlib
27197
+ from importlib.metadata import PackageNotFoundError, version
27198
+ from io import BytesIO
27199
+ import re
27200
+ import site
27201
+
27202
+ def release(value):
27203
+ # The approved ranges are inclusive/exclusive numeric releases. Accept
27204
+ # post and local builds, and leave prereleases outside the baseline.
27205
+ match = re.fullmatch(r"(?:0!)?(\d+(?:\.\d+)*)(?:(?:[._-]?(?:post|rev|r)[._-]?\d+)|-\d+)?(?:\+[a-z0-9._-]+)?", value.lower())
27206
+ if not match:
27207
+ return None
27208
+ parts = [int(part) for part in match[1].split(".")]
27209
+ while len(parts) > 1 and parts[-1] == 0:
27210
+ parts.pop()
27211
+ return tuple(parts)
27212
+
27213
+ def compatible(installed, requirement):
27214
+ minimum, before = requirement.split(">=", 1)[1].split(",<", 1)
27215
+ installed = release(installed)
27216
+ return installed is not None and release(minimum) <= installed < release(before)
27217
+
27218
+ def check_package(package):
27219
+ try:
27220
+ installed = version(package["name"])
27221
+ except PackageNotFoundError:
27222
+ return {**package, "status": "missing"}
27223
+ try:
27224
+ module = importlib.import_module(package["importName"])
27225
+ except Exception:
27226
+ status = "import-failed" if compatible(installed, package["requirement"]) else "incompatible"
27227
+ return {**package, "version": installed, "status": status}
27228
+ imported = getattr(module, "__version__", installed)
27229
+ if not isinstance(imported, str):
27230
+ imported = installed
27231
+ status = "ready" if compatible(imported, package["requirement"]) and compatible(installed, package["requirement"]) else "incompatible"
27232
+ return {**package, "version": imported, "status": status}
27233
+
27234
+ def example_image():
27235
+ from PIL import Image
27236
+
27237
+ contents = BytesIO()
27238
+ Image.new("RGB", (12, 12), "blue").save(contents, format="PNG")
27239
+ contents.seek(0)
27240
+ return contents
27241
+
27242
+ def check_word():
27243
+ from docx import Document
27244
+
27245
+ document = Document()
27246
+ document.add_paragraph("Forge")
27247
+ document.add_picture(example_image())
27248
+ contents = BytesIO()
27249
+ document.save(contents)
27250
+ contents.seek(0)
27251
+ reopened = Document(contents)
27252
+ return reopened.paragraphs[0].text == "Forge" and len(reopened.inline_shapes) == 1
27253
+
27254
+ def check_excel():
27255
+ from openpyxl import Workbook, load_workbook
27256
+ from openpyxl.drawing.image import Image
27257
+
27258
+ workbook = Workbook()
27259
+ workbook.active["A1"] = "Forge"
27260
+ workbook.active.add_image(Image(example_image()), "B2")
27261
+ contents = BytesIO()
27262
+ workbook.save(contents)
27263
+ contents.seek(0)
27264
+ reopened = load_workbook(contents)
27265
+ try:
27266
+ return reopened.active["A1"].value == "Forge" and len(reopened.active._images) == 1
27267
+ finally:
27268
+ reopened.close()
27269
+
27270
+ def check_powerpoint():
27271
+ from pptx import Presentation
27272
+ from pptx.enum.shapes import MSO_SHAPE_TYPE
27273
+ from pptx.util import Inches
27274
+
27275
+ presentation = Presentation()
27276
+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])
27277
+ slide.shapes.add_textbox(Inches(1), Inches(1), Inches(4), Inches(1)).text_frame.text = "Forge"
27278
+ slide.shapes.add_picture(example_image(), Inches(1), Inches(2))
27279
+ contents = BytesIO()
27280
+ presentation.save(contents)
27281
+ contents.seek(0)
27282
+ reopened = Presentation(contents)
27283
+ texts = [shape.text for shape in reopened.slides[0].shapes if shape.has_text_frame]
27284
+ pictures = [shape for shape in reopened.slides[0].shapes if shape.shape_type == MSO_SHAPE_TYPE.PICTURE]
27285
+ return "Forge" in texts and len(pictures) == 1
27286
+
27287
+ def check_document(check):
27288
+ try:
27289
+ return check()
27290
+ except Exception:
27291
+ return False
27292
+
27293
+ packages = [check_package(package) for package in json.loads(sys.argv[1])]
27294
+ ready = {package["name"] for package in packages if package["status"] == "ready"}
27295
+ result = {
27296
+ **identity,
27297
+ "virtualEnvironment": sys.prefix != sys.base_prefix,
27298
+ "userSiteEnabled": site.ENABLE_USER_SITE is True,
27299
+ "packages": packages,
27300
+ "documents": {
27301
+ "word": {"python-docx", "Pillow"} <= ready and check_document(check_word),
27302
+ "excel": {"openpyxl", "Pillow"} <= ready and check_document(check_excel),
27303
+ "powerpoint": {"python-pptx", "Pillow"} <= ready and check_document(check_powerpoint),
27304
+ },
27305
+ }
27306
+ print("${PROBE_MARKER}" + json.dumps(result))
27307
+ `;
27308
+ var BASELINE_KEY = createHash8("sha256").update(PROBE).update(JSON.stringify(PYTHON_REQUIREMENTS)).digest("hex");
27309
+ function needsInstall(entry) {
27310
+ return entry.status === "missing" || entry.status === "incompatible";
27311
+ }
27312
+ var startupChecks = /* @__PURE__ */ new Map();
27313
+ var selectionUnreadable = "N\xE3o foi poss\xEDvel ler a sele\xE7\xE3o Python do Forge. Selecione novamente o Python com --python.";
27314
+ function selectionPath(paths) {
27315
+ return path15.join(paths.forgeDir, "python-readiness.json");
27316
+ }
27317
+ function cachePath(paths) {
27318
+ return path15.join(paths.forgeDir, "python-readiness-cache.json");
27319
+ }
27320
+ function result(fields) {
27321
+ return { ...fields, checkedAt: (/* @__PURE__ */ new Date()).toISOString(), cached: false };
27322
+ }
27323
+ function unverified(reason, interpreter) {
27324
+ return result({ status: "unverified", interpreter, reason });
27325
+ }
27326
+ function selectPython(reason, interpreter) {
27327
+ return { ...unverified(reason, interpreter), requiresPythonSelection: true };
27328
+ }
27329
+ async function readSelection(paths) {
27330
+ let contents;
27331
+ try {
27332
+ contents = await readFile15(selectionPath(paths), "utf8");
27333
+ } catch (error45) {
27334
+ if (error45.code === "ENOENT") return void 0;
27335
+ throw error45;
27336
+ }
27337
+ const selected = JSON.parse(contents);
27338
+ if (typeof selected?.interpreter !== "string" || !path15.isAbsolute(selected.interpreter) || typeof selected.revision !== "string") {
27339
+ throw new Error("Invalid Python selection");
27340
+ }
27341
+ return selected;
27342
+ }
27343
+ async function readSelectedPython(paths) {
27344
+ return (await readSelection(paths).catch(() => void 0))?.interpreter;
27345
+ }
27346
+ async function readCache(paths) {
27347
+ try {
27348
+ const cache = JSON.parse(await readFile15(cachePath(paths), "utf8"));
27349
+ if (typeof cache.key === "string" && typeof cache.result?.checkedAt === "string" && ["ready", "not-ready", "unverified"].includes(cache.result.status)) return cache;
27350
+ } catch {
27351
+ }
27352
+ return void 0;
27353
+ }
27354
+ async function cacheKey(selection) {
27355
+ try {
27356
+ const executable = await stat3(selection.interpreter);
27357
+ if (!executable.isFile()) return void 0;
27358
+ const venvConfig = await stat3(path15.resolve(path15.dirname(selection.interpreter), "..", "pyvenv.cfg")).catch(() => void 0);
27359
+ return JSON.stringify([BASELINE_KEY, selection, executable.ino, executable.size, executable.mtimeMs, executable.ctimeMs, venvConfig?.mtimeMs]);
27360
+ } catch {
27361
+ return void 0;
27362
+ }
27363
+ }
27364
+ async function saveCache(paths, key, checked) {
27365
+ if (!key) return;
27366
+ const cache = { key, result: checked };
27367
+ await writeOwnerOnlyTextAtomic(cachePath(paths), `${JSON.stringify(cache)}
27368
+ `).catch(() => void 0);
27369
+ }
27370
+ async function probePython(interpreter) {
27371
+ if (!interpreter || !path15.isAbsolute(interpreter)) {
27372
+ return { checked: selectPython("Selecione um execut\xE1vel Python 3 atrav\xE9s de --python com o caminho absoluto.") };
27373
+ }
27374
+ try {
27375
+ const { stdout } = await runPython(interpreter, ["-B", "-c", PROBE, JSON.stringify(PYTHON_REQUIREMENTS)], {
27376
+ cwd: os5.homedir(),
27377
+ encoding: "utf8",
27378
+ timeout: 6e4,
27379
+ windowsHide: true
27380
+ });
27381
+ const record2 = stdout.split(/\r?\n/).reverse().find((line) => line.startsWith(PROBE_MARKER));
27382
+ const probe = JSON.parse(record2?.slice(PROBE_MARKER.length) ?? "null");
27383
+ if (!probe || typeof probe.interpreter !== "string" || !path15.isAbsolute(probe.interpreter) || typeof probe.pythonVersion !== "string") {
27384
+ return { checked: selectPython("O execut\xE1vel selecionado n\xE3o devolveu um diagn\xF3stico Python v\xE1lido.", interpreter) };
27385
+ }
27386
+ if (probe.supported === false) {
27387
+ return { checked: result({ interpreter: probe.interpreter, pythonVersion: probe.pythonVersion, status: "not-ready", reason: "Selecione Python 3.10 ou posterior.", requiresPythonSelection: true }) };
27388
+ }
27389
+ if (probe.supported !== true || !probe.documents || probe.packages?.length !== PYTHON_REQUIREMENTS.length) {
27390
+ return { checked: selectPython("O execut\xE1vel selecionado n\xE3o devolveu um diagn\xF3stico Python v\xE1lido.", interpreter) };
27391
+ }
27392
+ const details = { interpreter: probe.interpreter, pythonVersion: probe.pythonVersion, packages: probe.packages, documents: probe.documents };
27393
+ if (probe.packages.some(needsInstall)) {
27394
+ return { probe, checked: result({ ...details, status: "not-ready", reason: "O Python selecionado tem bibliotecas em falta ou incompat\xEDveis. Execute prepare para instalar as bibliotecas indicadas." }) };
27395
+ }
27396
+ if (probe.packages.some((entry) => entry.status === "import-failed")) {
27397
+ return { probe, checked: result({ ...details, status: "not-ready", reason: "Uma biblioteca instalada falhou ao importar. Envie o diagn\xF3stico ao suporte para reparar o ambiente ou selecionar outro Python." }) };
27398
+ }
27399
+ if (!probe.documents.word || !probe.documents.excel || !probe.documents.powerpoint) {
27400
+ return { probe, checked: result({ ...details, status: "not-ready", reason: "O Python selecionado n\xE3o concluiu o ensaio de Word, Excel ou PowerPoint com imagens. Envie o diagn\xF3stico ao suporte para verificar esse ambiente." }) };
27401
+ }
27402
+ return { probe, checked: result({ ...details, status: "ready" }) };
27403
+ } catch (error45) {
27404
+ const failure = error45;
27405
+ if (failure.code === "ENOENT") {
27406
+ return { checked: selectPython("O execut\xE1vel Python selecionado j\xE1 n\xE3o est\xE1 dispon\xEDvel. Selecione novamente o Python com --python.", interpreter) };
27407
+ }
27408
+ if (failure.code === "EACCES" || failure.code === "EPERM") {
27409
+ return { checked: selectPython("O utilizador atual n\xE3o tem permiss\xE3o para executar o Python selecionado.", interpreter) };
27410
+ }
27411
+ return { checked: unverified(failure.killed ? "O Python selecionado n\xE3o concluiu a verifica\xE7\xE3o no tempo dispon\xEDvel." : "N\xE3o foi poss\xEDvel verificar o Python selecionado.", interpreter) };
27412
+ }
27413
+ }
27414
+ async function probeSavedPython(interpreter) {
27415
+ const outcome = await probePython(interpreter);
27416
+ if (outcome.checked.interpreter && outcome.checked.interpreter !== interpreter) {
27417
+ return { checked: selectPython("O caminho guardado aponta agora para outro Python. Selecione novamente o Python com --python.", interpreter) };
27418
+ }
27419
+ return outcome;
27420
+ }
27421
+ async function checkStartupPythonReadiness(paths) {
27422
+ let selection;
27423
+ try {
27424
+ selection = await readSelection(paths);
27425
+ } catch {
27426
+ return selectPython(selectionUnreadable);
27427
+ }
27428
+ if (!selection) return (await probePython(void 0)).checked;
27429
+ if (selection.preparing) {
27430
+ return unverified("A prepara\xE7\xE3o do Python ainda n\xE3o foi conclu\xEDda. Consulte o resultado da prepara\xE7\xE3o ou retome o comando prepare.", selection.interpreter);
27431
+ }
27432
+ const [key, cache] = await Promise.all([cacheKey(selection), readCache(paths)]);
27433
+ const age = cache ? Date.now() - Date.parse(cache.result.checkedAt) : Number.NaN;
27434
+ if (cache && key && cache.key === key && age >= 0 && age < CACHE_MAX_AGE_MS) {
27435
+ return { ...cache.result, cached: true };
27436
+ }
27437
+ const inFlightKey = JSON.stringify([paths.forgeDir, selection.revision, key]);
27438
+ const ongoing = startupChecks.get(inFlightKey);
27439
+ if (ongoing) return ongoing;
27440
+ const checking = (async () => {
27441
+ const { checked } = await probeSavedPython(selection.interpreter);
27442
+ const current = await readSelection(paths).catch(() => void 0);
27443
+ if (current?.revision !== selection.revision || current.preparing) {
27444
+ return unverified("A sele\xE7\xE3o do Python mudou durante a verifica\xE7\xE3o. Volte a verificar o Python.");
27445
+ }
27446
+ await saveCache(paths, key, checked);
27447
+ return checked;
27448
+ })();
27449
+ startupChecks.set(inFlightKey, checking);
27450
+ try {
27451
+ return await checking;
27452
+ } finally {
27453
+ startupChecks.delete(inFlightKey);
27454
+ }
27455
+ }
27456
+
27457
+ // packages/cli/src/workPackPythonStartup.ts
27458
+ var PREPARE_COMMAND = `npm exec --yes --package=minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION} -- forge-python prepare`;
27459
+ function startWorkPackPythonCheck(paths, report) {
27460
+ let latestCheck = 0;
27461
+ async function check2() {
27462
+ const checkId = ++latestCheck;
27463
+ const readiness = await checkStartupPythonReadiness(paths).catch(async () => ({
27464
+ status: "unverified",
27465
+ interpreter: await readSelectedPython(paths),
27466
+ reason: "N\xE3o foi poss\xEDvel concluir a verifica\xE7\xE3o de Python.",
27467
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
27468
+ cached: false
27469
+ }));
27470
+ if (checkId === latestCheck) report(readiness);
27471
+ return readiness;
27472
+ }
27473
+ void readSelectedPython(paths).then((interpreter) => interpreter ? check2() : void 0);
27474
+ return {
27475
+ async skillInstruction(slug) {
27476
+ const requirements = await lstat8(path16.join(paths.skillsDir, slug, "requirements.txt")).catch(() => void 0);
27477
+ if (!requirements?.isFile()) return void 0;
27478
+ const readiness = await check2();
27479
+ const interpreter = readiness.interpreter ? interpreterInstruction(readiness.interpreter) : "Usa somente o Python escolhido na prepara\xE7\xE3o Forge.";
27480
+ if (readiness.status === "ready") return interpreter;
27481
+ return `${interpreter}
27482
+ ${pythonIssueMessage(readiness)} Informa a pessoa e aguarda que a prepara\xE7\xE3o seja confirmada antes de executar os scripts Python desta skill. Podes continuar as partes da tarefa que n\xE3o dependem de Python.`;
27483
+ }
27484
+ };
27485
+ }
27486
+ function pythonIssueKey(readiness) {
27487
+ if (readiness.status === "ready") return void 0;
27488
+ const failures = readiness.packages?.filter((item) => item.status !== "ready").map(({ name, status }) => [name, status]).sort();
27489
+ return createHash9("sha256").update(JSON.stringify([readiness.status, readiness.reason, failures ?? [], readiness.documents])).digest("hex");
27490
+ }
27491
+ function pythonIssueMessage(readiness) {
27492
+ const reason = readiness.reason ?? "A prepara\xE7\xE3o de Python est\xE1 por verificar neste computador.";
27493
+ const failedPackages = readiness.packages?.filter((item) => item.status !== "ready").map((item) => item.name) ?? [];
27494
+ const details = failedPackages.length ? ` Pacotes a verificar: ${failedPackages.join(", ")}.` : "";
27495
+ let action = `Para repetir a prepara\xE7\xE3o ap\xF3s autoriza\xE7\xE3o, usa ${PREPARE_COMMAND}.`;
27496
+ if (!readiness.interpreter || readiness.requiresPythonSelection) {
27497
+ action = `Segue as instru\xE7\xF5es Forge para escolher um Python suportado e usa ${PREPARE_COMMAND} --python <caminho absoluto>.`;
27498
+ } else {
27499
+ const repairable = readiness.packages?.some(({ status }) => status === "missing" || status === "incompatible");
27500
+ const failedTest = readiness.packages?.some(({ status }) => status === "import-failed") || readiness.documents?.excel === false || readiness.documents?.word === false || readiness.documents?.powerpoint === false;
27501
+ if (!repairable && failedTest) action = "Consulta o resultado da verifica\xE7\xE3o e pede ajuda \xE0 equipa de suporte se necess\xE1rio.";
27502
+ }
27503
+ return `${reason}${details} ${action}`;
27504
+ }
27505
+ function interpreterInstruction(interpreter) {
27506
+ return `Para executar scripts Python desta skill, usa o caminho absoluto registado nesta m\xE1quina (string JSON): ${JSON.stringify(interpreter)}. Usa esse caminho com as aspas adequadas \xE0 shell em cada chamada e mant\xE9m o mesmo Python ao seguir os exemplos da skill que indiquem python, python3 ou py.`;
27507
+ }
27508
+
27132
27509
  // packages/cli/src/workPackSyncPlugin.ts
27133
- var PLUGIN_VERSION = "0.1.55";
27510
+ var PLUGIN_VERSION = "0.1.57";
27134
27511
  var FORGE_DECISION_TIMEOUT_MS = 11e4;
27135
27512
  var STATUS_FILENAME = "work-pack-startup-status.json";
27513
+ var PYTHON_STATUS_FILENAME = "python-startup-status.json";
27136
27514
  var activeSync = /* @__PURE__ */ new Map();
27137
27515
  function isLocalConfig(options) {
27138
27516
  return Boolean(options && typeof options === "object" && "localConfig" in options && options.localConfig === true);
@@ -27158,7 +27536,7 @@ function createForgeTools(forgeBaseUrl, state) {
27158
27536
  function createEvidenceReporters(forgeBaseUrl, state) {
27159
27537
  const reportEvidence = async (sessionID, callID, slug, kind) => {
27160
27538
  const { forgeApiKey } = await readForgeCredentials(state.paths, forgeBaseUrl);
27161
- const credentialId = createHash8("sha256").update(forgeApiKey).digest("hex");
27539
+ const credentialId = createHash10("sha256").update(forgeApiKey).digest("hex");
27162
27540
  const report = skillUsageReporter(forgeBaseUrl, credentialId, (events) => fetch(`${forgeBaseUrl}/sync/evidence`, {
27163
27541
  method: "POST",
27164
27542
  redirect: "error",
@@ -27169,7 +27547,7 @@ function createEvidenceReporters(forgeBaseUrl, state) {
27169
27547
  report(sessionID, callID, slug, kind);
27170
27548
  };
27171
27549
  const reportReasoningLoop = (sessionID, outcome) => {
27172
- reportEvidence(sessionID, `reasoning-loop:${randomUUID5()}`, outcome, "reasoning_loop").catch(() => {
27550
+ reportEvidence(sessionID, `reasoning-loop:${randomUUID6()}`, outcome, "reasoning_loop").catch(() => {
27173
27551
  console.error("[Forge evidence] Reasoning guard identity unavailable; event not queued");
27174
27552
  });
27175
27553
  };
@@ -27177,7 +27555,7 @@ function createEvidenceReporters(forgeBaseUrl, state) {
27177
27555
  const slug = typeof name === "string" ? name.trim().toLowerCase() : "";
27178
27556
  if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)) return;
27179
27557
  try {
27180
- await readFile15(path15.join(state.paths.skillsDir, slug, ".forge-version"), "utf8");
27558
+ await readFile16(path17.join(state.paths.skillsDir, slug, ".forge-version"), "utf8");
27181
27559
  } catch {
27182
27560
  return;
27183
27561
  }
@@ -27192,7 +27570,7 @@ function createEvidenceReporters(forgeBaseUrl, state) {
27192
27570
  var ForgeWorkPackSyncServer = async (_input, options) => {
27193
27571
  const forgeBaseUrl = parseForgeBaseUrl(options);
27194
27572
  const state = await startupSync(forgeBaseUrl, isLocalConfig(options), () => observeRuntime(_input), _input);
27195
- const legacyPath = path15.join(state.paths.pluginDir, FORGE_EVIDENCE_PLUGIN_FILENAME);
27573
+ const legacyPath = path17.join(state.paths.pluginDir, FORGE_EVIDENCE_PLUGIN_FILENAME);
27196
27574
  const ownershipSymbol = /* @__PURE__ */ Symbol.for("minimal-forge.legacy-evidence-owners.v1");
27197
27575
  const shared = globalThis;
27198
27576
  const legacyOwners = shared[ownershipSymbol] ??= /* @__PURE__ */ new Set();
@@ -27212,7 +27590,7 @@ var ForgeWorkPackSyncServer = async (_input, options) => {
27212
27590
  const official = await skills.load(input.args?.name);
27213
27591
  if (official) {
27214
27592
  output.title = official.title;
27215
- output.output = official.output;
27593
+ output.output = await skillOutput(official, state.python);
27216
27594
  output.metadata = official.metadata;
27217
27595
  }
27218
27596
  if (official?.loaded === false || legacyOwners.has(legacyOwnerKey)) return;
@@ -27224,7 +27602,7 @@ var ForgeWorkPackSyncServer = async (_input, options) => {
27224
27602
  const name = Array.isArray(entry) ? entry[0] : entry;
27225
27603
  return name === legacyPath || name === pathToFileURL(legacyPath).href;
27226
27604
  });
27227
- const legacy = registered ? await readFile15(legacyPath, "utf8").catch(() => "") : "";
27605
+ const legacy = registered ? await readFile16(legacyPath, "utf8").catch(() => "") : "";
27228
27606
  const oldLegacyRegistered = registered && legacy.startsWith(FORGE_PLUGIN_HEADER) && legacy.includes("work_pack_invocation") && !legacy.includes("minimal-forge.skill-usage.v1");
27229
27607
  if (oldLegacyRegistered) legacyOwners.add(legacyOwnerKey);
27230
27608
  if (oldLegacyRegistered) await writeFile9(legacyPath, renderEvidencePlugin()).catch(() => {
@@ -27249,7 +27627,7 @@ async function ForgeWorkPackSyncSetup(ctx) {
27249
27627
  throw new Error("A pasta do motor ativo mudou. Confirme a liga\xE7\xE3o Forge neste perfil do OpenWork.");
27250
27628
  }
27251
27629
  const credentials = await readForgeCredentials(state.paths, forgeBaseUrl);
27252
- const canonical = objectRecord2(parseJsonc(await readFile15(state.paths.opencodeConfigPath, "utf8")));
27630
+ const canonical = objectRecord2(parseJsonc(await readFile16(state.paths.opencodeConfigPath, "utf8")));
27253
27631
  const config2 = renderOpenworkEngineConfig(state.manifest, credentials, state.paths, directory, canonical);
27254
27632
  if (state.partialWorkPackSync) {
27255
27633
  const companion = await inspectOpenworkEngineConfig(directory);
@@ -27266,11 +27644,11 @@ async function ForgeWorkPackSyncSetup(ctx) {
27266
27644
  syncedTools.catch(() => void 0);
27267
27645
  const { reportReasoningLoop, reportSkillInvocation } = createEvidenceReporters(forgeBaseUrl, { paths });
27268
27646
  const managedSkills = sync.then(
27269
- (state) => managedSkillSession(paths, state.manifest ?? state.failedManifest),
27270
- () => managedSkillSession(paths)
27647
+ async (state) => ({ skills: await managedSkillSession(paths, state.manifest ?? state.failedManifest), python: state.python }),
27648
+ async () => ({ skills: await managedSkillSession(paths), python: void 0 })
27271
27649
  );
27272
27650
  const directoryOf = sessionDirectoryResolver(ctx);
27273
- const registrations = Object.entries(createForgeTools(forgeBaseUrl, { paths, decisionBaseUrl: forgeBaseUrl })).filter(([name]) => name !== "forge_feedback").map(([name, shape]) => openCode2Tool(name, {
27651
+ const registrations = Object.entries(createForgeTools(forgeBaseUrl, { paths, decisionBaseUrl: forgeBaseUrl })).filter(([name]) => name !== "forge_feedback" || typeof ctx.permission?.assert === "function").map(([name, shape]) => openCode2Tool(name, {
27274
27652
  description: shape.description,
27275
27653
  args: shape.args,
27276
27654
  async execute(args, context) {
@@ -27278,19 +27656,21 @@ async function ForgeWorkPackSyncSetup(ctx) {
27278
27656
  context.abort.throwIfAborted();
27279
27657
  return tools[name].execute(args, context);
27280
27658
  }
27281
- }, directoryOf));
27659
+ }, directoryOf, ctx.permission));
27282
27660
  await ctx.tool.transform((editor) => {
27283
27661
  for (const registration of registrations) editor.add(registration);
27284
27662
  });
27285
27663
  await ctx.tool.hook("execute.before", async (event) => {
27286
27664
  if (!["edit", "write", "patch", "apply_patch"].includes(event.tool)) return;
27287
- await (await managedSkills).assertWritable(event.tool, event.input, ctx.location.directory);
27665
+ const { skills } = await managedSkills;
27666
+ await skills.assertWritable(event.tool, event.input, ctx.location.directory);
27288
27667
  });
27289
27668
  await ctx.tool.hook("execute.after", async (event) => {
27290
27669
  const call = completedSkillCall(event);
27291
27670
  if (!call || event.status !== "completed") return;
27292
- const official = await (await managedSkills).load(call.name);
27293
- if (official) event.result = { content: official.output, metadata: official.metadata };
27671
+ const { skills, python } = await managedSkills;
27672
+ const official = await skills.load(call.name);
27673
+ if (official) event.result = { content: await skillOutput(official, python), metadata: official.metadata };
27294
27674
  if (official?.loaded === false) return;
27295
27675
  try {
27296
27676
  await reportSkillInvocation(call.sessionID, call.callID, call.name);
@@ -27300,6 +27680,12 @@ async function ForgeWorkPackSyncSetup(ctx) {
27300
27680
  });
27301
27681
  return startReasoningLoopGuard(ctx, reportReasoningLoop);
27302
27682
  }
27683
+ async function skillOutput(official, python) {
27684
+ const instruction = official.loaded ? await python?.skillInstruction(official.metadata.name) : void 0;
27685
+ return instruction ? `${instruction}
27686
+
27687
+ ${official.output}` : official.output;
27688
+ }
27303
27689
  function reasoningLoopGuardClient(input) {
27304
27690
  if (!input || typeof input !== "object" || !("client" in input)) return void 0;
27305
27691
  const client = input.client;
@@ -27316,10 +27702,10 @@ function createForgeImageTool(forgeBaseUrl, gatewayBaseUrl, paths) {
27316
27702
  referencePath: tool.schema.string().optional().describe("Caminho absoluto de uma imagem PNG, JPEG ou WebP a editar, at\xE9 2,5 MB")
27317
27703
  },
27318
27704
  async execute(args, context) {
27319
- const requestId = randomUUID5();
27705
+ const requestId = randomUUID6();
27320
27706
  let referenceDataUrl;
27321
27707
  if (args.referencePath) {
27322
- const bytes = await readFile15(args.referencePath);
27708
+ const bytes = await readFile16(args.referencePath);
27323
27709
  if (bytes.byteLength > 25e5) throw new Error("A imagem de refer\xEAncia \xE9 demasiado grande. Reduza-a antes de tentar novamente.");
27324
27710
  const mime = bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])) ? "image/png" : bytes.subarray(0, 3).equals(Buffer.from([255, 216, 255])) ? "image/jpeg" : bytes.subarray(0, 4).toString() === "RIFF" && bytes.subarray(8, 12).toString() === "WEBP" ? "image/webp" : void 0;
27325
27711
  if (!mime) throw new Error("A refer\xEAncia tem de ser PNG, JPEG ou WebP.");
@@ -27345,14 +27731,14 @@ function createForgeImageTool(forgeBaseUrl, gatewayBaseUrl, paths) {
27345
27731
  if (image.byteLength > 8 * 1024 * 1024 || !image.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) {
27346
27732
  throw new Error(`O PNG recebido \xE9 inv\xE1lido. Refer\xEAncia: ${requestId}`);
27347
27733
  }
27348
- const destination = path15.join(context.directory, `forge-image-${requestId}.png`);
27734
+ const destination = path17.join(context.directory, `forge-image-${requestId}.png`);
27349
27735
  await writeFile9(destination, image, { flag: "wx" });
27350
27736
  const reset = body.quota && new Intl.DateTimeFormat("pt-PT", { dateStyle: "long", timeZone: "Europe/Lisbon" }).format(new Date(body.quota.resetsAt));
27351
27737
  const remaining = body.quota ? ` Restam ${body.quota.remaining} imagens at\xE9 ${reset}.` : "";
27352
27738
  return {
27353
27739
  title: "Imagem criada",
27354
27740
  output: `Imagem guardada em ${destination}.${remaining} A pessoa j\xE1 v\xEA a imagem na conversa. Se n\xE3o a conseguires ver, isso n\xE3o \xE9 um erro: n\xE3o o reportes.`,
27355
- attachments: [{ type: "file", mime: "image/png", url: `data:image/png;base64,${body.b64_json}`, filename: path15.basename(destination) }]
27741
+ attachments: [{ type: "file", mime: "image/png", url: `data:image/png;base64,${body.b64_json}`, filename: path17.basename(destination) }]
27356
27742
  };
27357
27743
  }
27358
27744
  });
@@ -27394,9 +27780,9 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths, responseD
27394
27780
  let requestBody;
27395
27781
  if (fromFile) {
27396
27782
  const file2 = await fileInsideWorkspace(context.directory, args.request_file);
27397
- const planFile = path15.join(path15.dirname(path15.dirname(file2)), "plan.json");
27398
- if (!responseDirectory && path15.basename(path15.dirname(file2)) === "requests" && await fileExists(planFile)) {
27399
- const plan = JSON.parse(await readFile15(planFile, "utf8"));
27783
+ const planFile = path17.join(path17.dirname(path17.dirname(file2)), "plan.json");
27784
+ if (!responseDirectory && path17.basename(path17.dirname(file2)) === "requests" && await fileExists(planFile)) {
27785
+ const plan = JSON.parse(await readFile16(planFile, "utf8"));
27400
27786
  if (plan?.engine === "jev-batch" && plan.model === "typesafe/jev-1.13" && Array.isArray(plan.batches)) {
27401
27787
  let batch;
27402
27788
  for (const candidate of plan.batches) {
@@ -27409,7 +27795,7 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths, responseD
27409
27795
  return createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths).execute({ plan_file: planFile, batch_id: batch.batch_id }, context);
27410
27796
  }
27411
27797
  }
27412
- const raw = await readFile15(file2, "utf8");
27798
+ const raw = await readFile16(file2, "utf8");
27413
27799
  if (Buffer.byteLength(raw) > 512 * 1024) throw new Error("O ficheiro de pedido excede 512 KiB.");
27414
27800
  let parsed;
27415
27801
  try {
@@ -27428,11 +27814,11 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths, responseD
27428
27814
  if (args.state === void 0 || !args.questions || Object.keys(args.questions).length === 0) throw new Error("Indica state e questions.");
27429
27815
  requestBody = { state: args.state, questions: args.questions };
27430
27816
  }
27431
- const responseDir = await mkdtemp2(path15.join(responseDirectory ?? context.directory, ".forge-decision-"));
27432
- const responseFile = path15.join(responseDir, "response.json");
27817
+ const responseDir = await mkdtemp2(path17.join(responseDirectory ?? context.directory, ".forge-decision-"));
27818
+ const responseFile = path17.join(responseDir, "response.json");
27433
27819
  try {
27434
27820
  const credentials = await readForgeCredentials(paths, forgeBaseUrl);
27435
- const probeFile = path15.join(responseDir, ".write-test");
27821
+ const probeFile = path17.join(responseDir, ".write-test");
27436
27822
  await writeFile9(probeFile, "", { flag: "wx", mode: 384 });
27437
27823
  await unlink2(probeFile);
27438
27824
  context.abort.throwIfAborted();
@@ -27482,24 +27868,24 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths, responseD
27482
27868
  }
27483
27869
  async function fileInsideWorkspace(directory, candidate) {
27484
27870
  const workspace = await realpath3(directory);
27485
- const file2 = await realpath3(path15.resolve(workspace, candidate));
27486
- const relative = path15.relative(workspace, file2);
27487
- if (!relative || (relative === ".." || relative.startsWith(`..${path15.sep}`)) || path15.isAbsolute(relative)) throw new Error("O ficheiro tem de estar dentro do workspace.");
27871
+ const file2 = await realpath3(path17.resolve(workspace, candidate));
27872
+ const relative = path17.relative(workspace, file2);
27873
+ if (!relative || (relative === ".." || relative.startsWith(`..${path17.sep}`)) || path17.isAbsolute(relative)) throw new Error("O ficheiro tem de estar dentro do workspace.");
27488
27874
  return file2;
27489
27875
  }
27490
27876
  async function fileExists(candidate) {
27491
27877
  try {
27492
- await stat3(candidate);
27878
+ await stat4(candidate);
27493
27879
  return true;
27494
27880
  } catch (error45) {
27495
27881
  if (error45.code === "ENOENT") return false;
27496
27882
  throw error45;
27497
27883
  }
27498
27884
  }
27499
- async function ensureJevDirectory(directory, filesystem = { stat: stat3, mkdir: mkdir8 }) {
27885
+ async function ensureJevDirectory(directory, filesystem = { stat: stat4, mkdir: mkdir8 }) {
27500
27886
  try {
27501
27887
  if ((await filesystem.stat(directory)).isDirectory()) return;
27502
- throw new Error(`O destino ${path15.basename(directory)} existe, mas n\xE3o \xE9 uma pasta. Preservar o conte\xFAdo e verificar o caminho.`);
27888
+ throw new Error(`O destino ${path17.basename(directory)} existe, mas n\xE3o \xE9 uma pasta. Preservar o conte\xFAdo e verificar o caminho.`);
27503
27889
  } catch (error45) {
27504
27890
  if (error45.code !== "ENOENT") throw error45;
27505
27891
  }
@@ -27531,7 +27917,7 @@ function validSmallDecision(answer, question) {
27531
27917
  return Object.keys(criteria).length === Object.keys(probabilities).length && Object.keys(criteria).every((key) => decisionProbability(probabilities[key]));
27532
27918
  }
27533
27919
  async function validateSavedDecision(file2, request, smallPlan) {
27534
- const body = JSON.parse(await readFile15(file2, "utf8"));
27920
+ const body = JSON.parse(await readFile16(file2, "utf8"));
27535
27921
  const answers = body.answers;
27536
27922
  const questions = request.questions;
27537
27923
  const usage = body.usage;
@@ -27555,19 +27941,19 @@ async function acquireJevRunLock(lockDir) {
27555
27941
  let owner;
27556
27942
  let ownerRaw;
27557
27943
  try {
27558
- ownerRaw = await readFile15(path15.join(lockDir, "owner.json"), "utf8");
27944
+ ownerRaw = await readFile16(path17.join(lockDir, "owner.json"), "utf8");
27559
27945
  owner = JSON.parse(ownerRaw);
27560
27946
  } catch {
27561
27947
  throw new Error("Chamada interrompida com lock sem identifica\xE7\xE3o; n\xE3o \xE9 poss\xEDvel confirmar que terminou. Preservar o lock e verificar a execu\xE7\xE3o.");
27562
27948
  }
27563
- if (!Number.isInteger(owner.pid) || owner.pid <= 0 || owner.hostname && owner.hostname !== os5.hostname()) {
27949
+ if (!Number.isInteger(owner.pid) || owner.pid <= 0 || owner.hostname && owner.hostname !== os6.hostname()) {
27564
27950
  throw new Error("N\xE3o \xE9 poss\xEDvel confirmar que a execu\xE7\xE3o do lock terminou nesta m\xE1quina. Preservar o lock.");
27565
27951
  }
27566
27952
  try {
27567
27953
  process.kill(owner.pid, 0);
27568
27954
  } catch (error45) {
27569
27955
  if (error45.code === "ESRCH") {
27570
- const archived = `${lockDir}.interrupted-${createHash8("sha256").update(ownerRaw).digest("hex")}`;
27956
+ const archived = `${lockDir}.interrupted-${createHash10("sha256").update(ownerRaw).digest("hex")}`;
27571
27957
  await rename9(lockDir, archived);
27572
27958
  try {
27573
27959
  await mkdir8(lockDir);
@@ -27589,38 +27975,38 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27589
27975
  },
27590
27976
  async execute(args, context) {
27591
27977
  const planFile = await fileInsideWorkspace(context.directory, args.plan_file);
27592
- if (path15.basename(planFile) !== "plan.json" || path15.basename(path15.dirname(planFile)) !== "jev") throw new Error("Indica o ficheiro jev/plan.json.");
27593
- const runDir = path15.dirname(path15.dirname(planFile));
27594
- const plan = objectRecord2(JSON.parse(await readFile15(planFile, "utf8")));
27978
+ if (path17.basename(planFile) !== "plan.json" || path17.basename(path17.dirname(planFile)) !== "jev") throw new Error("Indica o ficheiro jev/plan.json.");
27979
+ const runDir = path17.dirname(path17.dirname(planFile));
27980
+ const plan = objectRecord2(JSON.parse(await readFile16(planFile, "utf8")));
27595
27981
  const smallPlan = plan.schema_version === 2 && Array.isArray(plan.requests) && plan.batches === void 0;
27596
27982
  if (plan.engine !== "jev-batch" || plan.model !== "typesafe/jev-1.13" || !smallPlan && (!Array.isArray(plan.batches) || plan.requests !== void 0)) throw new Error("O plano Jev \xE9 inv\xE1lido.");
27597
27983
  const allBatches = smallPlan ? plan.requests.map((request, index) => {
27598
27984
  const id = String(index).padStart(4, "0");
27599
27985
  return {
27600
27986
  batch_id: id,
27601
- request_file: path15.join(runDir, "jev", "requests", `${id}.json`),
27602
- request_fingerprint: createHash8("sha256").update(canonicalJson(request)).digest("hex")
27987
+ request_file: path17.join(runDir, "jev", "requests", `${id}.json`),
27988
+ request_fingerprint: createHash10("sha256").update(canonicalJson(request)).digest("hex")
27603
27989
  };
27604
27990
  }) : plan.batches.map(objectRecord2);
27605
27991
  const batches = args.batch_id ? allBatches.filter((batch) => batch.batch_id === args.batch_id) : allBatches;
27606
27992
  if (args.batch_id && batches.length !== 1) throw new Error("O lote indicado n\xE3o pertence ao plano Jev.");
27607
- const responsePath = path15.join(runDir, "jev", "responses");
27993
+ const responsePath = path17.join(runDir, "jev", "responses");
27608
27994
  await ensureJevDirectory(responsePath);
27609
27995
  const responseDir = await fileInsideWorkspace(context.directory, responsePath);
27610
- if (path15.dirname(responseDir) !== path15.join(runDir, "jev")) throw new Error("A pasta de respostas tem de pertencer ao run Jev.");
27611
- const lockDir = path15.join(runDir, "jev", ".decide-run.lock");
27996
+ if (path17.dirname(responseDir) !== path17.join(runDir, "jev")) throw new Error("A pasta de respostas tem de pertencer ao run Jev.");
27997
+ const lockDir = path17.join(runDir, "jev", ".decide-run.lock");
27612
27998
  const interrupted = await acquireJevRunLock(lockDir);
27613
27999
  let saved = 0;
27614
28000
  let skipped = 0;
27615
28001
  let recovered = 0;
27616
28002
  const repeated = [];
27617
28003
  try {
27618
- const ownerFile = path15.join(lockDir, "owner.json");
27619
- await writeOwnerOnlyTextAtomic(ownerFile, JSON.stringify({ ...interrupted, pid: process.pid, hostname: os5.hostname(), started_at: (/* @__PURE__ */ new Date()).toISOString() }));
27620
- const attemptsPath = path15.join(runDir, "jev", "attempts");
28004
+ const ownerFile = path17.join(lockDir, "owner.json");
28005
+ await writeOwnerOnlyTextAtomic(ownerFile, JSON.stringify({ ...interrupted, pid: process.pid, hostname: os6.hostname(), started_at: (/* @__PURE__ */ new Date()).toISOString() }));
28006
+ const attemptsPath = path17.join(runDir, "jev", "attempts");
27621
28007
  await ensureJevDirectory(attemptsPath);
27622
28008
  const attemptsDir = await fileInsideWorkspace(context.directory, attemptsPath);
27623
- if (path15.dirname(attemptsDir) !== path15.join(runDir, "jev")) throw new Error("A pasta de tentativas tem de pertencer ao run Jev.");
28009
+ if (path17.dirname(attemptsDir) !== path17.join(runDir, "jev")) throw new Error("A pasta de tentativas tem de pertencer ao run Jev.");
27624
28010
  for (const batch of batches) {
27625
28011
  context.abort.throwIfAborted();
27626
28012
  const batchId = batch.batch_id;
@@ -27628,17 +28014,17 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27628
28014
  if (typeof batchId !== "string" || !validBatchId.test(batchId) || typeof batch.request_file !== "string" || typeof batch.request_fingerprint !== "string") {
27629
28015
  throw new Error("O plano Jev cont\xE9m um lote inv\xE1lido.");
27630
28016
  }
27631
- const acceptedFile = path15.join(runDir, "jev", "accepted", `${batchId}.json`);
27632
- const responseFile = path15.join(responseDir, smallPlan ? `${batchId}.json` : `${batchId}.response.json`);
28017
+ const acceptedFile = path17.join(runDir, "jev", "accepted", `${batchId}.json`);
28018
+ const responseFile = path17.join(responseDir, smallPlan ? `${batchId}.json` : `${batchId}.response.json`);
27633
28019
  const requestFile = await fileInsideWorkspace(context.directory, batch.request_file);
27634
- if (path15.dirname(requestFile) !== path15.join(runDir, "jev", "requests")) throw new Error(`${batchId}: pedido fora do run.`);
27635
- const rawRequest = await readFile15(requestFile, "utf8");
28020
+ if (path17.dirname(requestFile) !== path17.join(runDir, "jev", "requests")) throw new Error(`${batchId}: pedido fora do run.`);
28021
+ const rawRequest = await readFile16(requestFile, "utf8");
27636
28022
  if (Buffer.byteLength(rawRequest) > 512 * 1024) throw new Error("O ficheiro de pedido excede 512 KiB.");
27637
28023
  const request = objectRecord2(JSON.parse(rawRequest));
27638
28024
  const questions = objectRecord2(request.questions);
27639
28025
  if (request.state === void 0 || !Object.keys(questions).length) throw new Error("O pedido deve conter state e questions.");
27640
28026
  if (request.model !== void 0 && request.model !== plan.model) throw new Error("O modelo do pedido n\xE3o corresponde ao Jev configurado.");
27641
- const fingerprint = createHash8("sha256").update(canonicalJson(request)).digest("hex");
28027
+ const fingerprint = createHash10("sha256").update(canonicalJson(request)).digest("hex");
27642
28028
  if (fingerprint !== batch.request_fingerprint) throw new Error(`${batchId}: fingerprint do pedido n\xE3o corresponde ao plano.`);
27643
28029
  if (await fileExists(acceptedFile)) {
27644
28030
  if (smallPlan) {
@@ -27659,9 +28045,9 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27659
28045
  skipped++;
27660
28046
  continue;
27661
28047
  }
27662
- const attemptsFile = path15.join(attemptsDir, `${batchId}.json`);
28048
+ const attemptsFile = path17.join(attemptsDir, `${batchId}.json`);
27663
28049
  let attempts = { request_fingerprint: fingerprint, attempts: 0, response_files: [] };
27664
- if (await fileExists(attemptsFile)) attempts = JSON.parse(await readFile15(attemptsFile, "utf8"));
28050
+ if (await fileExists(attemptsFile)) attempts = JSON.parse(await readFile16(attemptsFile, "utf8"));
27665
28051
  else if (interrupted.batch_id === batchId) {
27666
28052
  if (interrupted.request_fingerprint !== fingerprint) throw new Error(`${batchId}: fingerprint da chamada interrompida n\xE3o corresponde ao plano.`);
27667
28053
  attempts.attempts = 1;
@@ -27674,13 +28060,13 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27674
28060
  if (!await fileExists(attemptsFile) && attempts.attempts > 0) await persistAttempts();
27675
28061
  const stop = (error45, detail = {}) => JSON.stringify({ verified: false, saved, skipped, recovered, repeated, stopped_at: batchId, ...detail, error: error45 });
27676
28062
  const recoverResponse = async () => {
27677
- const legacyAllocations = interrupted.batch_id === batchId && interrupted.request_fingerprint === fingerprint ? (await readdir8(responseDir)).filter((name) => name.startsWith(".forge-decision-")).map((name) => path15.join(responseDir, name, "response.json")) : [];
28063
+ const legacyAllocations = interrupted.batch_id === batchId && interrupted.request_fingerprint === fingerprint ? (await readdir8(responseDir)).filter((name) => name.startsWith(".forge-decision-")).map((name) => path17.join(responseDir, name, "response.json")) : [];
27678
28064
  const candidates = [...attempts.response_files, ...legacyAllocations];
27679
28065
  for (const candidate of new Set(candidates)) {
27680
28066
  if (typeof candidate !== "string") throw new Error("Registo de recupera\xE7\xE3o inv\xE1lido.");
27681
28067
  if (!await fileExists(candidate)) continue;
27682
28068
  const file2 = await fileInsideWorkspace(context.directory, candidate);
27683
- if (path15.dirname(path15.dirname(file2)) !== responseDir) throw new Error("Resposta recuper\xE1vel fora da pasta do lote.");
28069
+ if (path17.dirname(path17.dirname(file2)) !== responseDir) throw new Error("Resposta recuper\xE1vel fora da pasta do lote.");
27684
28070
  try {
27685
28071
  await validateSavedDecision(file2, request, smallPlan);
27686
28072
  } catch {
@@ -27701,15 +28087,15 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27701
28087
  if (attempts.attempts >= 2) return stop("A \xFAnica repeti\xE7\xE3o deste lote j\xE1 foi usada. Preservar o progresso e recuperar a resposta do hist\xF3rico acess\xEDvel.");
27702
28088
  const previousAttempts = attempts.attempts;
27703
28089
  const decide = createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths, responseDir, async (allocated) => {
27704
- await writeOwnerOnlyTextAtomic(ownerFile, JSON.stringify({ pid: process.pid, hostname: os5.hostname(), batch_id: batchId, request_fingerprint: fingerprint, started_at: (/* @__PURE__ */ new Date()).toISOString() }));
28090
+ await writeOwnerOnlyTextAtomic(ownerFile, JSON.stringify({ pid: process.pid, hostname: os6.hostname(), batch_id: batchId, request_fingerprint: fingerprint, started_at: (/* @__PURE__ */ new Date()).toISOString() }));
27705
28091
  const next = { ...attempts, attempts: attempts.attempts + 1, response_files: [...attempts.response_files, allocated] };
27706
28092
  if (next.attempts === 2) next.repeated_at = (/* @__PURE__ */ new Date()).toISOString();
27707
28093
  await writeOwnerOnlyTextAtomic(attemptsFile, JSON.stringify(next));
27708
28094
  attempts = next;
27709
28095
  });
27710
- let result;
28096
+ let result2;
27711
28097
  try {
27712
- result = JSON.parse(await decide.execute({ state: request.state, questions }, context));
28098
+ result2 = JSON.parse(await decide.execute({ state: request.state, questions }, context));
27713
28099
  } catch (error45) {
27714
28100
  if (error45 instanceof ForgeDecisionRejectedError) {
27715
28101
  attempts.attempts = previousAttempts;
@@ -27725,8 +28111,8 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27725
28111
  continue;
27726
28112
  }
27727
28113
  if (attempts.attempts === 2 && !repeated.includes(batchId)) repeated.push(batchId);
27728
- if (typeof result.response_file !== "string") return stop(String(result.persistence_error), { recovery_response: result, persistence_code: result.persistence_code });
27729
- source = result.response_file;
28114
+ if (typeof result2.response_file !== "string") return stop(String(result2.persistence_error), { recovery_response: result2, persistence_code: result2.persistence_code });
28115
+ source = result2.response_file;
27730
28116
  try {
27731
28117
  await validateSavedDecision(source, request, smallPlan);
27732
28118
  } catch (error45) {
@@ -27739,7 +28125,7 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27739
28125
  let identical = false;
27740
28126
  if (error45.code === "EEXIST") {
27741
28127
  try {
27742
- identical = await readFile15(source, "utf8") === await readFile15(responseFile, "utf8");
28128
+ identical = await readFile16(source, "utf8") === await readFile16(responseFile, "utf8");
27743
28129
  } catch {
27744
28130
  }
27745
28131
  }
@@ -27747,7 +28133,7 @@ function createForgeDecisionRunTool(forgeBaseUrl, decisionBaseUrl, paths) {
27747
28133
  return stop("Resposta conclu\xEDda mas n\xE3o guardada no destino do lote; resolver a grava\xE7\xE3o e retomar sem nova chamada.", { recovery_file: source, persistence_code: error45.code });
27748
28134
  }
27749
28135
  }
27750
- await unlink2(source).then(() => rmdir2(path15.dirname(source))).catch(() => void 0);
28136
+ await unlink2(source).then(() => rmdir2(path17.dirname(source))).catch(() => void 0);
27751
28137
  saved++;
27752
28138
  if (args.batch_id) return JSON.stringify({ ...await validateSavedDecision(responseFile, request, smallPlan), response_file: responseFile, repeated });
27753
28139
  }
@@ -27805,7 +28191,7 @@ function createForgeFeedbackTool(forgeBaseUrl, paths) {
27805
28191
  message: tool.schema.string().trim().min(1).max(WORKER_FEEDBACK_MAX_MESSAGE_LENGTH).describe("Texto completo e exato aprovado pela pessoa, at\xE9 24.000 caracteres; n\xE3o enviar conversa nem logs em bruto")
27806
28192
  },
27807
28193
  async execute(args, context) {
27808
- await context.ask({ permission: "forge_feedback", patterns: [args.kind], always: [], metadata: {} });
28194
+ await context.ask({ permission: "forge_feedback", patterns: [args.kind, args.message], always: [], metadata: { kind: args.kind, message: args.message } });
27809
28195
  context.abort.throwIfAborted();
27810
28196
  const credentials = await readForgeCredentials(paths, forgeBaseUrl);
27811
28197
  const response = await fetch(`${forgeBaseUrl}/sync/feedback`, {
@@ -27843,26 +28229,21 @@ async function synchronizeAtStartup(forgeBaseUrl, observe, localConfig, input) {
27843
28229
  manifest = await fetchManifest(credentials, PLUGIN_VERSION);
27844
28230
  decisionBaseUrl = resolveDecisionBaseUrl(manifest.gatewayBaseUrl, forgeBaseUrl);
27845
28231
  forgeConfigVerified = true;
27846
- const result = localConfig ? await syncLocalWorker(paths, credentials, manifest) : await applyWorkPackManifest(paths, credentials, manifest, {});
28232
+ const result2 = localConfig ? await syncLocalWorker(paths, credentials, manifest) : await applyWorkPackManifest(paths, credentials, manifest, {});
27847
28233
  if (localConfig) {
27848
- appliedLocalSync = { manifest, partialWorkPackSync: result };
27849
- const config2 = objectRecord2(parseJsonc(await readFile15(paths.opencodeConfigPath, "utf8")));
28234
+ appliedLocalSync = { manifest, partialWorkPackSync: result2 };
28235
+ const config2 = objectRecord2(parseJsonc(await readFile16(paths.opencodeConfigPath, "utf8")));
27850
28236
  const targetVersion = configuredWorkPackSyncPluginVersion(config2);
27851
28237
  if (targetVersion) pluginUpdate = { targetVersion, restartRequired: targetVersion !== PLUGIN_VERSION };
27852
28238
  if (pluginUpdate?.restartRequired) {
27853
- const message = "Atualiza\xE7\xE3o preparada. Quando terminar o trabalho, feche e volte a abrir o OpenWork para a aplicar.";
27854
- console.info(`[Forge] ${message}`);
27855
- const client = input && typeof input === "object" ? input.client : void 0;
27856
- if (client?.tui?.showToast) {
27857
- void Promise.resolve().then(() => client.tui.showToast({ body: { title: "Forge", message, variant: "info", duration: 1e4 } })).catch(() => void 0);
27858
- }
28239
+ startupNotice(input, "Atualiza\xE7\xE3o preparada. Quando terminar o trabalho, feche e volte a abrir o OpenWork para a aplicar.", "info");
27859
28240
  }
27860
28241
  }
27861
- await reportWorkPackObservations(credentials, "sync", result.workPackObservations, runtime, PLUGIN_VERSION);
27862
- const failures = result.workPacks.outcomes.filter(
28242
+ await reportWorkPackObservations(credentials, "sync", result2.workPackObservations, runtime, PLUGIN_VERSION);
28243
+ const failures = result2.workPacks.outcomes.filter(
27863
28244
  (outcome) => outcome.status === "failed" || outcome.status === "recovery-uncertain"
27864
28245
  );
27865
- if (failures.length > 0 || result.workPacks.receipt.status === "failed") {
28246
+ if (failures.length > 0 || result2.workPacks.receipt.status === "failed") {
27866
28247
  const summary = failures.map((outcome) => `${outcome.slug}:${outcome.code ?? outcome.status}`).join(", ");
27867
28248
  throw new Error(`Sincroniza\xE7\xE3o autom\xE1tica de Work Packs falhou${summary ? ` (${summary})` : ""}`);
27868
28249
  }
@@ -27871,12 +28252,13 @@ async function synchronizeAtStartup(forgeBaseUrl, observe, localConfig, input) {
27871
28252
  version: 1,
27872
28253
  pluginVersion: PLUGIN_VERSION,
27873
28254
  ...pluginUpdate ? { pluginUpdate } : {},
27874
- status: result.workPacks.receipt.status,
28255
+ status: result2.workPacks.receipt.status,
27875
28256
  syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
27876
- installed: result.installed,
27877
- removed: result.removed
28257
+ installed: result2.installed,
28258
+ removed: result2.removed
27878
28259
  });
27879
- return { paths, before, after, forgeConfigVerified, decisionBaseUrl, manifest };
28260
+ const python = watchStartupPython(paths, input);
28261
+ return { paths, before, after, forgeConfigVerified, decisionBaseUrl, manifest, python };
27880
28262
  } catch (error45) {
27881
28263
  const message = safeErrorMessage(error45);
27882
28264
  console.error("[Forge work-pack sync] Startup sync failed:", message);
@@ -27888,17 +28270,44 @@ async function synchronizeAtStartup(forgeBaseUrl, observe, localConfig, input) {
27888
28270
  attemptedAt: (/* @__PURE__ */ new Date()).toISOString(),
27889
28271
  message
27890
28272
  }).catch(() => void 0);
28273
+ const python = watchStartupPython(paths, input);
27891
28274
  if (credentials) await reportFailure(credentials, "sync", new Error(message), runtime, PLUGIN_VERSION);
27892
28275
  if (localConfig && !forgeConfigVerified && credentials) {
27893
28276
  decisionBaseUrl = await savedGatewayBaseUrl(paths, credentials, forgeBaseUrl) ?? decisionBaseUrl;
27894
28277
  }
27895
28278
  const after = await managedProjectionNames(paths).catch(() => before);
27896
- return { paths, before, after, forgeConfigVerified, decisionBaseUrl, failedManifest: manifest, ...appliedLocalSync };
28279
+ return { paths, before, after, forgeConfigVerified, decisionBaseUrl, python, failedManifest: manifest, ...appliedLocalSync };
27897
28280
  }
27898
28281
  }
28282
+ function startupNotice(input, message, variant) {
28283
+ console.info(`[Forge] ${message}`);
28284
+ const client = input && typeof input === "object" ? input.client : void 0;
28285
+ if (client?.tui?.showToast) {
28286
+ void Promise.resolve().then(() => client.tui.showToast({ body: { title: "Forge", message, variant, duration: 1e4 } })).catch(() => void 0);
28287
+ }
28288
+ }
28289
+ function watchStartupPython(paths, input) {
28290
+ const file2 = path17.join(paths.forgeDir, PYTHON_STATUS_FILENAME);
28291
+ let writing = Promise.resolve();
28292
+ return startWorkPackPythonCheck(paths, (readiness) => {
28293
+ writing = writing.then(async () => {
28294
+ const issue2 = pythonIssueKey(readiness);
28295
+ if (!issue2) {
28296
+ await rm6(file2, { force: true });
28297
+ return;
28298
+ }
28299
+ const current = await readFile16(file2, "utf8").then((raw) => objectRecord2(JSON.parse(raw))).catch(() => ({}));
28300
+ if (current.issue !== issue2 || Object.keys(current).length !== 1) {
28301
+ await writeOwnerOnlyTextAtomic(file2, `${JSON.stringify({ issue: issue2 })}
28302
+ `);
28303
+ }
28304
+ if (current.issue !== issue2) startupNotice(input, pythonIssueMessage(readiness), "warning");
28305
+ }).catch(() => void 0);
28306
+ });
28307
+ }
27899
28308
  async function savedGatewayBaseUrl(paths, credentials, forgeBaseUrl) {
27900
28309
  try {
27901
- const config2 = objectRecord2(parseJsonc(await readFile15(paths.opencodeConfigPath, "utf8")));
28310
+ const config2 = objectRecord2(parseJsonc(await readFile16(paths.opencodeConfigPath, "utf8")));
27902
28311
  const options = objectRecord2(objectRecord2(objectRecord2(config2.provider).forge).options);
27903
28312
  if (options.apiKey !== credentials.forgeApiKey || typeof options.baseURL !== "string" || !options.baseURL.endsWith("/v1")) return void 0;
27904
28313
  const origin = options.baseURL.slice(0, -"/v1".length);
@@ -27923,7 +28332,7 @@ function resolveStartupPaths() {
27923
28332
  return resolvePaths(void 0, void 0, env);
27924
28333
  }
27925
28334
  async function readForgeCredentials(paths, forgeBaseUrl) {
27926
- const raw = await readFile15(paths.opencodeAuthPath, "utf8").catch((error45) => {
28335
+ const raw = await readFile16(paths.opencodeAuthPath, "utf8").catch((error45) => {
27927
28336
  if (error45.code === "ENOENT") return void 0;
27928
28337
  throw error45;
27929
28338
  });
@@ -27968,8 +28377,8 @@ function objectRecord2(value) {
27968
28377
  }
27969
28378
  async function writeStatus(paths, value) {
27970
28379
  await mkdir8(paths.forgeDir, { recursive: true });
27971
- const target = path15.join(paths.forgeDir, STATUS_FILENAME);
27972
- const temporary = path15.join(paths.forgeDir, `.${STATUS_FILENAME}.${process.pid}.tmp`);
28380
+ const target = path17.join(paths.forgeDir, STATUS_FILENAME);
28381
+ const temporary = path17.join(paths.forgeDir, `.${STATUS_FILENAME}.${process.pid}.tmp`);
27973
28382
  await writeFile9(temporary, `${JSON.stringify(value, null, 2)}
27974
28383
  `, { mode: 384 });
27975
28384
  await rename9(temporary, target);