@dudousxd/nestjs-agent-react 0.7.1 → 0.7.3

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.cjs CHANGED
@@ -391,6 +391,13 @@ var AgentChatTransport = class {
391
391
  errorText: event.error
392
392
  });
393
393
  break;
394
+ case "tool-output-denied":
395
+ ensureStep();
396
+ controller.enqueue({
397
+ type: "tool-output-denied",
398
+ toolCallId: event.id
399
+ });
400
+ break;
394
401
  default:
395
402
  break;
396
403
  }
@@ -2453,6 +2460,24 @@ function isPromise(value) {
2453
2460
  __name(isPromise, "isPromise");
2454
2461
 
2455
2462
  // src/stored-message-to-ui-message.ts
2463
+ var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
2464
+ function isRefusal(result) {
2465
+ if (result.denied === true) {
2466
+ return true;
2467
+ }
2468
+ const { output } = result;
2469
+ return output !== null && typeof output === "object" && "rejected" in output && output.rejected === true;
2470
+ }
2471
+ __name(isRefusal, "isRefusal");
2472
+ function refusalReason(result) {
2473
+ const { output } = result;
2474
+ if (output !== null && typeof output === "object" && "reason" in output) {
2475
+ const reason = output.reason;
2476
+ return typeof reason === "string" && reason !== import_nestjs_agent_core.DEFAULT_REFUSAL_REASON ? reason : void 0;
2477
+ }
2478
+ return void 0;
2479
+ }
2480
+ __name(refusalReason, "refusalReason");
2456
2481
  function storedMessageToUiMessage(message) {
2457
2482
  const parts = [];
2458
2483
  if (message.content) {
@@ -2480,7 +2505,21 @@ function storedMessageToUiMessage(message) {
2480
2505
  toolKind: toolKind2
2481
2506
  }
2482
2507
  } : {},
2483
- ...result !== void 0 ? {
2508
+ ...result !== void 0 ? isRefusal(result) ? {
2509
+ // A declined action is NOT an available output. Reloading a thread used to bring one
2510
+ // back as `output-available` carrying `{ rejected: true }`, which a card reads as a
2511
+ // result — so the action a person refused was drawn, after a refresh, as one that
2512
+ // had been carried out.
2513
+ state: "output-denied",
2514
+ input: call.input,
2515
+ approval: {
2516
+ id: call.id,
2517
+ approved: false,
2518
+ ...refusalReason(result) !== void 0 ? {
2519
+ reason: refusalReason(result)
2520
+ } : {}
2521
+ }
2522
+ } : {
2484
2523
  state: "output-available",
2485
2524
  input: call.input,
2486
2525
  output: result.output