@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.
@@ -1,5 +1,5 @@
1
1
  import { AgentEngine } from '@dudousxd/nestjs-agent';
2
- import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeEngineOptions } from '../engine-0YkBLWZR.cjs';
2
+ import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeEngineOptions } from '../engine-Cp5uysaN.cjs';
3
3
  import { AgentRunner, AgentStore, AgentRunInput, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
4
4
  import { WorkflowService } from '@dudousxd/nestjs-durable';
5
5
  import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
@@ -1,5 +1,5 @@
1
1
  import { AgentEngine } from '@dudousxd/nestjs-agent';
2
- import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeEngineOptions } from '../engine-0YkBLWZR.js';
2
+ import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeEngineOptions } from '../engine-Cp5uysaN.js';
3
3
  import { AgentRunner, AgentStore, AgentRunInput, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
4
4
  import { WorkflowService } from '@dudousxd/nestjs-durable';
5
5
  import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
@@ -132,7 +132,7 @@ import { toJsonSchemaCompat } from "@modelcontextprotocol/sdk/server/zod-json-sc
132
132
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
133
133
 
134
134
  // src/turn.ts
135
- import { encodeStreamEvent, settleElicitation } from "@dudousxd/nestjs-agent-core";
135
+ import { encodeStreamEvent, resolveToolConfirmation, settleElicitation } from "@dudousxd/nestjs-agent-core";
136
136
  import { ConflictException } from "@nestjs/common";
137
137
 
138
138
  // src/forms.ts
@@ -1002,6 +1002,8 @@ ${delta}` : delta;
1002
1002
  }
1003
1003
  const ttlMs = requirement.ttlMs !== void 0 && Number.isFinite(requirement.ttlMs) && requirement.ttlMs > 0 ? Math.floor(requirement.ttlMs) : void 0;
1004
1004
  const expiresAt = ttlMs !== void 0 ? new Date(Date.now() + ttlMs).toISOString() : void 0;
1005
+ const tool = this.a.approvalPresentation?.(action);
1006
+ const confirmation = tool !== void 0 ? resolveToolConfirmation(tool.name, args, tool.presentation) : void 0;
1005
1007
  this.segment.calls.push({
1006
1008
  id: req.id,
1007
1009
  name: action,
@@ -1016,6 +1018,9 @@ ${delta}` : delta;
1016
1018
  toolType: "action",
1017
1019
  input: args,
1018
1020
  status: "pending_approval",
1021
+ ...confirmation !== void 0 ? {
1022
+ confirmation
1023
+ } : {},
1019
1024
  runId: this.a.runId,
1020
1025
  approver: requirement.approver,
1021
1026
  ...expiresAt !== void 0 ? {
@@ -1033,6 +1038,9 @@ ${delta}` : delta;
1033
1038
  kind: "approval-requested",
1034
1039
  id: req.id,
1035
1040
  approver: requirement.approver,
1041
+ ...confirmation !== void 0 ? {
1042
+ confirmation
1043
+ } : {},
1036
1044
  ...expiresAt !== void 0 ? {
1037
1045
  expiresAt
1038
1046
  } : {}
@@ -1813,6 +1821,25 @@ var OpenCodeTurns = class {
1813
1821
  get toolsServer() {
1814
1822
  return this.settings.tools?.server ?? "aviary";
1815
1823
  }
1824
+ /** The app tool an OpenCode permission `action` names, and its presentation — `undefined` for a built-in. */
1825
+ presentationOf(action) {
1826
+ if (this.settings.tools === void 0) return void 0;
1827
+ const server = this.toolsServer;
1828
+ for (const prefix of [
1829
+ `${server}.`,
1830
+ `${server}_`
1831
+ ]) {
1832
+ if (!action.startsWith(prefix)) continue;
1833
+ const spec = this.registry.spec(action.slice(prefix.length));
1834
+ if (spec !== void 0) return {
1835
+ name: spec.name,
1836
+ ...spec.presentation !== void 0 ? {
1837
+ presentation: spec.presentation
1838
+ } : {}
1839
+ };
1840
+ }
1841
+ return void 0;
1842
+ }
1816
1843
  /** The roles policy a turn's tools are gated by (the agent's own). */
1817
1844
  rolesPolicyFor(input) {
1818
1845
  return this.deps.forAgent(input.agentName).rolesPolicy;
@@ -2545,6 +2572,9 @@ ${body}
2545
2572
  agentName: input.agentName
2546
2573
  } : {}
2547
2574
  }), "approvalFor"),
2575
+ // An app tool reaches OpenCode as `<server>.<name>` / `<server>_<name>`: its own presentation
2576
+ // words the approval card. OpenCode's built-ins (`bash`, `edit`) have none.
2577
+ approvalPresentation: /* @__PURE__ */ __name((action) => this.presentationOf(action), "approvalPresentation"),
2548
2578
  modelLabel: input.model ?? "opencode",
2549
2579
  priceStep: /* @__PURE__ */ __name((step) => this.priceStep(step), "priceStep"),
2550
2580
  ...spent !== void 0 ? {