utils.cjs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ToolInputParsingException = exports._configHasToolCallId = exports._isToolCall = void 0;
  4. function _isToolCall(toolCall) {
  5. return !!(toolCall &&
  6. typeof toolCall === "object" &&
  7. "type" in toolCall &&
  8. toolCall.type === "tool_call");
  9. }
  10. exports._isToolCall = _isToolCall;
  11. function _configHasToolCallId(config) {
  12. return !!(config &&
  13. typeof config === "object" &&
  14. "toolCall" in config &&
  15. config.toolCall != null &&
  16. typeof config.toolCall === "object" &&
  17. "id" in config.toolCall &&
  18. typeof config.toolCall.id === "string");
  19. }
  20. exports._configHasToolCallId = _configHasToolCallId;
  21. /**
  22. * Custom error class used to handle exceptions related to tool input parsing.
  23. * It extends the built-in `Error` class and adds an optional `output`
  24. * property that can hold the output that caused the exception.
  25. */
  26. class ToolInputParsingException extends Error {
  27. constructor(message, output) {
  28. super(message);
  29. Object.defineProperty(this, "output", {
  30. enumerable: true,
  31. configurable: true,
  32. writable: true,
  33. value: void 0
  34. });
  35. this.output = output;
  36. }
  37. }
  38. exports.ToolInputParsingException = ToolInputParsingException;