@dudousxd/nestjs-agent-react 0.7.0 → 0.7.2

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.d.cts CHANGED
@@ -1088,26 +1088,6 @@ interface ComposerAutocomplete {
1088
1088
  */
1089
1089
  declare function useComposerAutocomplete(options: UseComposerAutocompleteOptions): ComposerAutocomplete;
1090
1090
 
1091
- /**
1092
- * Convert a persisted `StoredMessage` (the agent-lib's on-disk shape) into an AI SDK v7
1093
- * `UIMessage` so a loaded thread can seed `useChat`'s `initialMessages` / `messages`.
1094
- *
1095
- * The lib stores a message as flat `content` text plus `toolCalls`/`toolResults` arrays; the SDK
1096
- * renders from `parts`. This maps:
1097
- * - `content` → a single `text` part (skipped when empty).
1098
- * - each `attachment` → a `file` part (image/PDF) so the user bubble re-renders its
1099
- * thumbnails on a reloaded thread.
1100
- * - each `toolCall` → a `tool-<name>` part, pairing its `toolResult` (matched by id):
1101
- * - a result found → `output-available` state, carrying `output`.
1102
- * - no result found → `input-available` state (the call never finished, e.g. the run was
1103
- * interrupted) — `output` is omitted, never a fabricated value.
1104
- * When the store reports the tool's kind (`'read' | 'action'`), it rides along as
1105
- * `toolMetadata.toolKind` so a UI can render an approval affordance for `action` tools
1106
- * without hardcoding tool-name sets, matching how live-streamed tool parts carry it.
1107
- *
1108
- * Live streaming still arrives as fully-typed SDK tool parts (see `AgentChatTransport`); this
1109
- * converter only feeds replayed history, so the tool cards render the same either way.
1110
- */
1111
1091
  declare function storedMessageToUiMessage(message: StoredMessage): UIMessage;
1112
1092
 
1113
1093
  /**
package/dist/index.d.ts CHANGED
@@ -1088,26 +1088,6 @@ interface ComposerAutocomplete {
1088
1088
  */
1089
1089
  declare function useComposerAutocomplete(options: UseComposerAutocompleteOptions): ComposerAutocomplete;
1090
1090
 
1091
- /**
1092
- * Convert a persisted `StoredMessage` (the agent-lib's on-disk shape) into an AI SDK v7
1093
- * `UIMessage` so a loaded thread can seed `useChat`'s `initialMessages` / `messages`.
1094
- *
1095
- * The lib stores a message as flat `content` text plus `toolCalls`/`toolResults` arrays; the SDK
1096
- * renders from `parts`. This maps:
1097
- * - `content` → a single `text` part (skipped when empty).
1098
- * - each `attachment` → a `file` part (image/PDF) so the user bubble re-renders its
1099
- * thumbnails on a reloaded thread.
1100
- * - each `toolCall` → a `tool-<name>` part, pairing its `toolResult` (matched by id):
1101
- * - a result found → `output-available` state, carrying `output`.
1102
- * - no result found → `input-available` state (the call never finished, e.g. the run was
1103
- * interrupted) — `output` is omitted, never a fabricated value.
1104
- * When the store reports the tool's kind (`'read' | 'action'`), it rides along as
1105
- * `toolMetadata.toolKind` so a UI can render an approval affordance for `action` tools
1106
- * without hardcoding tool-name sets, matching how live-streamed tool parts carry it.
1107
- *
1108
- * Live streaming still arrives as fully-typed SDK tool parts (see `AgentChatTransport`); this
1109
- * converter only feeds replayed history, so the tool cards render the same either way.
1110
- */
1111
1091
  declare function storedMessageToUiMessage(message: StoredMessage): UIMessage;
1112
1092
 
1113
1093
  /**
package/dist/index.js CHANGED
@@ -329,6 +329,13 @@ var AgentChatTransport = class {
329
329
  errorText: event.error
330
330
  });
331
331
  break;
332
+ case "tool-output-denied":
333
+ ensureStep();
334
+ controller.enqueue({
335
+ type: "tool-output-denied",
336
+ toolCallId: event.id
337
+ });
338
+ break;
332
339
  default:
333
340
  break;
334
341
  }
@@ -2391,6 +2398,24 @@ function isPromise(value) {
2391
2398
  __name(isPromise, "isPromise");
2392
2399
 
2393
2400
  // src/stored-message-to-ui-message.ts
2401
+ import { DEFAULT_REFUSAL_REASON } from "@dudousxd/nestjs-agent-core";
2402
+ function isRefusal(result) {
2403
+ if (result.denied === true) {
2404
+ return true;
2405
+ }
2406
+ const { output } = result;
2407
+ return output !== null && typeof output === "object" && "rejected" in output && output.rejected === true;
2408
+ }
2409
+ __name(isRefusal, "isRefusal");
2410
+ function refusalReason(result) {
2411
+ const { output } = result;
2412
+ if (output !== null && typeof output === "object" && "reason" in output) {
2413
+ const reason = output.reason;
2414
+ return typeof reason === "string" && reason !== DEFAULT_REFUSAL_REASON ? reason : void 0;
2415
+ }
2416
+ return void 0;
2417
+ }
2418
+ __name(refusalReason, "refusalReason");
2394
2419
  function storedMessageToUiMessage(message) {
2395
2420
  const parts = [];
2396
2421
  if (message.content) {
@@ -2418,7 +2443,21 @@ function storedMessageToUiMessage(message) {
2418
2443
  toolKind: toolKind2
2419
2444
  }
2420
2445
  } : {},
2421
- ...result !== void 0 ? {
2446
+ ...result !== void 0 ? isRefusal(result) ? {
2447
+ // A declined action is NOT an available output. Reloading a thread used to bring one
2448
+ // back as `output-available` carrying `{ rejected: true }`, which a card reads as a
2449
+ // result — so the action a person refused was drawn, after a refresh, as one that
2450
+ // had been carried out.
2451
+ state: "output-denied",
2452
+ input: call.input,
2453
+ approval: {
2454
+ id: call.id,
2455
+ approved: false,
2456
+ ...refusalReason(result) !== void 0 ? {
2457
+ reason: refusalReason(result)
2458
+ } : {}
2459
+ }
2460
+ } : {
2422
2461
  state: "output-available",
2423
2462
  input: call.input,
2424
2463
  output: result.output