@dudousxd/nestjs-agent-opencode 0.2.1 → 0.3.0

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.
@@ -1030,6 +1030,8 @@ ${delta}` : delta;
1030
1030
  }
1031
1031
  const ttlMs = requirement.ttlMs !== void 0 && Number.isFinite(requirement.ttlMs) && requirement.ttlMs > 0 ? Math.floor(requirement.ttlMs) : void 0;
1032
1032
  const expiresAt = ttlMs !== void 0 ? new Date(Date.now() + ttlMs).toISOString() : void 0;
1033
+ const tool = this.a.approvalPresentation?.(action);
1034
+ const confirmation = tool !== void 0 ? (0, import_nestjs_agent_core2.resolveToolConfirmation)(tool.name, args, tool.presentation) : void 0;
1033
1035
  this.segment.calls.push({
1034
1036
  id: req.id,
1035
1037
  name: action,
@@ -1044,6 +1046,9 @@ ${delta}` : delta;
1044
1046
  toolType: "action",
1045
1047
  input: args,
1046
1048
  status: "pending_approval",
1049
+ ...confirmation !== void 0 ? {
1050
+ confirmation
1051
+ } : {},
1047
1052
  runId: this.a.runId,
1048
1053
  approver: requirement.approver,
1049
1054
  ...expiresAt !== void 0 ? {
@@ -1061,6 +1066,9 @@ ${delta}` : delta;
1061
1066
  kind: "approval-requested",
1062
1067
  id: req.id,
1063
1068
  approver: requirement.approver,
1069
+ ...confirmation !== void 0 ? {
1070
+ confirmation
1071
+ } : {},
1064
1072
  ...expiresAt !== void 0 ? {
1065
1073
  expiresAt
1066
1074
  } : {}
@@ -1841,6 +1849,25 @@ var OpenCodeTurns = class {
1841
1849
  get toolsServer() {
1842
1850
  return this.settings.tools?.server ?? "aviary";
1843
1851
  }
1852
+ /** The app tool an OpenCode permission `action` names, and its presentation — `undefined` for a built-in. */
1853
+ presentationOf(action) {
1854
+ if (this.settings.tools === void 0) return void 0;
1855
+ const server = this.toolsServer;
1856
+ for (const prefix of [
1857
+ `${server}.`,
1858
+ `${server}_`
1859
+ ]) {
1860
+ if (!action.startsWith(prefix)) continue;
1861
+ const spec = this.registry.spec(action.slice(prefix.length));
1862
+ if (spec !== void 0) return {
1863
+ name: spec.name,
1864
+ ...spec.presentation !== void 0 ? {
1865
+ presentation: spec.presentation
1866
+ } : {}
1867
+ };
1868
+ }
1869
+ return void 0;
1870
+ }
1844
1871
  /** The roles policy a turn's tools are gated by (the agent's own). */
1845
1872
  rolesPolicyFor(input) {
1846
1873
  return this.deps.forAgent(input.agentName).rolesPolicy;
@@ -2573,6 +2600,9 @@ ${body}
2573
2600
  agentName: input.agentName
2574
2601
  } : {}
2575
2602
  }), "approvalFor"),
2603
+ // An app tool reaches OpenCode as `<server>.<name>` / `<server>_<name>`: its own presentation
2604
+ // words the approval card. OpenCode's built-ins (`bash`, `edit`) have none.
2605
+ approvalPresentation: /* @__PURE__ */ __name((action) => this.presentationOf(action), "approvalPresentation"),
2576
2606
  modelLabel: input.model ?? "opencode",
2577
2607
  priceStep: /* @__PURE__ */ __name((step) => this.priceStep(step), "priceStep"),
2578
2608
  ...spent !== void 0 ? {