@doclo/core 0.1.6 → 0.1.8

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.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProviderVendor, A as AccessMethod } from './validation-CMvSxIJl.js';
2
- export { G as AggregatedMetrics, B as BBox, r as CategorizeNodeConfig, t as ChunkMetadata, v as ChunkNodeConfig, u as ChunkOutput, n as CitationConfig, k as CitationSourceType, w as CombineNodeConfig, U as CompatibilityRule, C as ConsensusConfig, e as ConsensusMetadata, d as ConsensusRunResult, D as DocumentIR, b as DocumentIRExtras, y as EnhancedExtractionSchema, s as ExtractInputMode, E as ExtractNodeConfig, a0 as ExtractedImage, m as FieldCitation, F as FieldVotingDetails, H as FlowContext, a7 as FlowExecutionError, h as FlowInput, i as FlowInputValidation, j as FlowResult, a8 as FlowValidationError, I as IRLine, a as IRPage, X as JSONSchemaNode, c as LLMJsonProvider, L as LLMProvider, _ as LanguageOptions, l as LineCitation, g as MaybeWithConsensusMetadata, M as MultimodalInput, a9 as NODE_COMPATIBILITY_MATRIX, J as NodeCtx, Q as NodeDef, K as NodeTypeInfo, T as NodeTypeName, N as NormalizedBBox, O as OCRProvider, a1 as OCRProviderOptions, x as OutputNodeConfig, o as OutputWithCitations, f as OutputWithConsensus, Z as PageRangeOptions, p as ParseNodeConfig, Y as ProcessingMode, a3 as ProviderCitation, ak as ProviderIdentity, ai as RESERVED_VARIABLES, R as ReasoningConfig, $ as SegmentationResult, S as SplitDocument, q as SplitNodeConfig, z as StepMetric, V as VLMProvider, a2 as VLMProviderOptions, W as ValidationResult, a4 as aggregateMetrics, ag as canStartForEachItemFlow, ao as createIdentity, ac as getCompatibleTargets, ab as getNodeTypeInfo, aa as getNodeTypeName, ad as getSuggestedConnections, af as getValidForEachStarters, an as isLocalEndpoint, a5 as node, am as parseProviderString, aj as protectReservedVariables, a6 as runPipeline, al as toProviderString, ah as validateJson, ae as validateNodeConnection } from './validation-CMvSxIJl.js';
1
+ import { P as ProviderVendor, A as AccessMethod } from './validation-WrnG3UMe.js';
2
+ export { G as AggregatedMetrics, B as BBox, r as CategorizeNodeConfig, t as ChunkMetadata, v as ChunkNodeConfig, u as ChunkOutput, n as CitationConfig, k as CitationSourceType, w as CombineNodeConfig, U as CompatibilityRule, C as ConsensusConfig, e as ConsensusMetadata, d as ConsensusRunResult, D as DocumentIR, b as DocumentIRExtras, y as EnhancedExtractionSchema, s as ExtractInputMode, E as ExtractNodeConfig, a0 as ExtractedImage, m as FieldCitation, F as FieldVotingDetails, H as FlowContext, a8 as FlowExecutionError, h as FlowInput, i as FlowInputValidation, j as FlowResult, a4 as FlowStepLocation, a9 as FlowValidationError, I as IRLine, a as IRPage, X as JSONSchemaNode, c as LLMJsonProvider, L as LLMProvider, _ as LanguageOptions, l as LineCitation, g as MaybeWithConsensusMetadata, M as MultimodalInput, aa as NODE_COMPATIBILITY_MATRIX, J as NodeCtx, Q as NodeDef, K as NodeTypeInfo, T as NodeTypeName, N as NormalizedBBox, O as OCRProvider, a1 as OCRProviderOptions, x as OutputNodeConfig, o as OutputWithCitations, f as OutputWithConsensus, Z as PageRangeOptions, p as ParseNodeConfig, Y as ProcessingMode, a3 as ProviderCitation, am as ProviderIdentity, aj as RESERVED_VARIABLES, R as ReasoningConfig, $ as SegmentationResult, S as SplitDocument, q as SplitNodeConfig, z as StepMetric, V as VLMProvider, a2 as VLMProviderOptions, W as ValidationResult, a5 as aggregateMetrics, ah as canStartForEachItemFlow, aq as createIdentity, al as extractErrorMessage, ad as getCompatibleTargets, ac as getNodeTypeInfo, ab as getNodeTypeName, ae as getSuggestedConnections, ag as getValidForEachStarters, ap as isLocalEndpoint, a6 as node, ao as parseProviderString, ak as protectReservedVariables, a7 as runPipeline, an as toProviderString, ai as validateJson, af as validateNodeConnection } from './validation-WrnG3UMe.js';
3
3
  export { getDocumentPageCount, getPDFPageCount, getPageCountMetadata, getTotalPageCount, splitPDFIntoChunks } from './pdf-utils.js';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -50,8 +50,34 @@ async function runPipeline(steps, input, observabilityContext, flowArtifacts) {
50
50
  }
51
51
  return { output: acc, artifacts, metrics };
52
52
  }
53
+ function extractErrorMessage(errorText) {
54
+ if (errorText.length < 10 || !errorText.trim().startsWith("{")) {
55
+ return errorText;
56
+ }
57
+ try {
58
+ const parsed = JSON.parse(errorText);
59
+ if (parsed.detail) {
60
+ return parsed.detail;
61
+ }
62
+ if (parsed.error?.message) {
63
+ return parsed.error.message;
64
+ }
65
+ if (typeof parsed.error === "string") {
66
+ return parsed.error;
67
+ }
68
+ if (parsed.message) {
69
+ return parsed.message;
70
+ }
71
+ if (parsed.error?.status && parsed.error?.message) {
72
+ return `${parsed.error.status}: ${parsed.error.message}`;
73
+ }
74
+ return errorText.length > 200 ? errorText.substring(0, 200) + "..." : errorText;
75
+ } catch {
76
+ return errorText.length > 500 ? errorText.substring(0, 500) + "..." : errorText;
77
+ }
78
+ }
53
79
  var FlowExecutionError = class _FlowExecutionError extends Error {
54
- constructor(message, failedStep, failedStepIndex, failedStepType, completedSteps, originalError, partialArtifacts) {
80
+ constructor(message, failedStep, failedStepIndex, failedStepType, completedSteps, originalError, partialArtifacts, flowPath, allCompletedSteps) {
55
81
  super(message);
56
82
  this.failedStep = failedStep;
57
83
  this.failedStepIndex = failedStepIndex;
@@ -59,11 +85,43 @@ var FlowExecutionError = class _FlowExecutionError extends Error {
59
85
  this.completedSteps = completedSteps;
60
86
  this.originalError = originalError;
61
87
  this.partialArtifacts = partialArtifacts;
88
+ this.flowPath = flowPath;
89
+ this.allCompletedSteps = allCompletedSteps;
62
90
  this.name = "FlowExecutionError";
63
91
  if (Error.captureStackTrace) {
64
92
  Error.captureStackTrace(this, _FlowExecutionError);
65
93
  }
66
94
  }
95
+ /**
96
+ * Returns a formatted string showing the execution path.
97
+ * Example: "parse → conditional:Invoice → extract"
98
+ */
99
+ getFormattedPath() {
100
+ if (!this.flowPath || this.flowPath.length === 0) {
101
+ return this.failedStep;
102
+ }
103
+ return this.flowPath.map((loc) => {
104
+ let label = loc.stepId;
105
+ if (loc.branch) {
106
+ label += `:${loc.branch}`;
107
+ }
108
+ if (loc.itemIndex !== void 0) {
109
+ label += `[${loc.itemIndex}]`;
110
+ }
111
+ return label;
112
+ }).join(" \u2192 ");
113
+ }
114
+ /**
115
+ * Returns the root cause error (innermost originalError).
116
+ * Useful when errors are nested multiple levels deep.
117
+ */
118
+ getRootCause() {
119
+ let cause = this.originalError;
120
+ while (cause instanceof _FlowExecutionError && cause.originalError) {
121
+ cause = cause.originalError;
122
+ }
123
+ return cause;
124
+ }
67
125
  };
68
126
  var FlowValidationError = class _FlowValidationError extends Error {
69
127
  constructor(message, reason, suggestions, sourceNode, targetNode, sourceOutputType, targetInputTypes) {
@@ -2253,6 +2311,7 @@ export {
2253
2311
  detectMimeTypeFromBase64Async,
2254
2312
  detectMimeTypeFromBytes,
2255
2313
  extractBase64,
2314
+ extractErrorMessage,
2256
2315
  getAllModels,
2257
2316
  getAllProviders,
2258
2317
  getCheapestProviderFor,