avantgate 1.3.0 → 1.4.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.
package/dist/index.js CHANGED
@@ -33,11 +33,15 @@ __export(index_exports, {
33
33
  PromptRegistry: () => PromptRegistry,
34
34
  PromptTemplate: () => PromptTemplate,
35
35
  SEED_MODEL_PRICES: () => SEED_MODEL_PRICES,
36
+ WorkflowSagaRollbackError: () => WorkflowSagaRollbackError,
37
+ WorkflowValidationError: () => WorkflowValidationError,
36
38
  ZenLLMControlLayer: () => AvantGateControlLayer,
37
39
  calculateCostUSD: () => calculateCostUSD,
38
40
  createAvantGate: () => createAvantGate,
39
41
  createHttpProviderClient: () => createHttpProviderClient,
40
42
  createLLMControlLayer: () => createLLMControlLayer,
43
+ defineWorkflow: () => defineWorkflow,
44
+ executeWorkflow: () => executeWorkflow,
41
45
  extractAndCleanJSON: () => extractAndCleanJSON,
42
46
  resolveModelPrice: () => resolveModelPrice,
43
47
  resolveModelPriceAsync: () => resolveModelPriceAsync,
@@ -1629,6 +1633,476 @@ var PromptRegistry = class {
1629
1633
  this.registry.clear();
1630
1634
  }
1631
1635
  };
1636
+
1637
+ // src/agent/errors.ts
1638
+ var StepSuspendedError = class extends Error {
1639
+ stepId;
1640
+ workflowId;
1641
+ metadata;
1642
+ constructor(stepId, workflowId, metadata) {
1643
+ super(`Step execution suspended for human approval: [${workflowId}::${stepId}]`);
1644
+ this.name = "StepSuspendedError";
1645
+ this.stepId = stepId;
1646
+ this.workflowId = workflowId;
1647
+ this.metadata = metadata;
1648
+ }
1649
+ };
1650
+ var PiiLeakError = class extends Error {
1651
+ toolName;
1652
+ maskedCount;
1653
+ constructor(toolName, maskedCount) {
1654
+ super(`PII leak detected in tool output for "${toolName}" (${maskedCount} occurrences detected).`);
1655
+ this.name = "PiiLeakError";
1656
+ this.toolName = toolName;
1657
+ this.maskedCount = maskedCount;
1658
+ }
1659
+ };
1660
+ var ToolAccessDeniedError = class extends Error {
1661
+ toolName;
1662
+ requiredRole;
1663
+ reason;
1664
+ constructor(toolName, reasonOrRole) {
1665
+ const isRole = Boolean(reasonOrRole && !reasonOrRole.includes(" "));
1666
+ const roleMsg = isRole ? ` (requires role "${reasonOrRole}")` : "";
1667
+ const reasonMsg = reasonOrRole && !isRole ? `: ${reasonOrRole}` : "";
1668
+ super(`Access denied for tool "${toolName}"${roleMsg}${reasonMsg}.`);
1669
+ this.name = "ToolAccessDeniedError";
1670
+ this.toolName = toolName;
1671
+ if (isRole) {
1672
+ this.requiredRole = reasonOrRole;
1673
+ } else {
1674
+ this.reason = reasonOrRole;
1675
+ }
1676
+ }
1677
+ };
1678
+ var DtoValidationError = class extends Error {
1679
+ toolName;
1680
+ issues;
1681
+ constructor(toolName, message, issues = []) {
1682
+ super(`LLM DTO validation failed for tool "${toolName}": ${message}`);
1683
+ this.name = "DtoValidationError";
1684
+ this.toolName = toolName;
1685
+ this.issues = issues;
1686
+ }
1687
+ };
1688
+
1689
+ // src/agent/guardrails.ts
1690
+ function sanitizeString(value) {
1691
+ const result = sanitizePII(value);
1692
+ return { text: result.text, count: result.maskedCount };
1693
+ }
1694
+ function sanitizeArray(items, options, visited) {
1695
+ let totalCount = 0;
1696
+ const sanitized = items.map((item) => {
1697
+ const res = recursivelySanitize(item, options, visited);
1698
+ totalCount += res.count;
1699
+ return res.sanitized;
1700
+ });
1701
+ return { sanitized, count: totalCount };
1702
+ }
1703
+ function sanitizeObject(target, options, visited) {
1704
+ let totalCount = 0;
1705
+ const copy = {};
1706
+ for (const [key, val] of Object.entries(target)) {
1707
+ const res = recursivelySanitize(val, options, visited);
1708
+ copy[key] = res.sanitized;
1709
+ totalCount += res.count;
1710
+ }
1711
+ return { sanitized: copy, count: totalCount };
1712
+ }
1713
+ function recursivelySanitize(data, options, visited = /* @__PURE__ */ new WeakSet()) {
1714
+ if (typeof data === "string") {
1715
+ const res = sanitizeString(data);
1716
+ return { sanitized: res.text, count: res.count };
1717
+ }
1718
+ if (data !== null && typeof data === "object") {
1719
+ if (visited.has(data)) {
1720
+ return { sanitized: "[CIRCULAR_REFERENCE]", count: 0 };
1721
+ }
1722
+ visited.add(data);
1723
+ if (Array.isArray(data)) {
1724
+ return sanitizeArray(data, options, visited);
1725
+ }
1726
+ return sanitizeObject(data, options, visited);
1727
+ }
1728
+ return { sanitized: data, count: 0 };
1729
+ }
1730
+ function auditToolResult(data, options) {
1731
+ const { sanitized, count } = recursivelySanitize(data, options);
1732
+ if (options.throwOnPii && count > 0) {
1733
+ throw new PiiLeakError(options.toolName, count);
1734
+ }
1735
+ return {
1736
+ sanitizedData: sanitized,
1737
+ maskedCount: count
1738
+ };
1739
+ }
1740
+
1741
+ // src/agent/isolated-tool.ts
1742
+ async function verifyDataAccessGuard(guard, args, context, toolIdentifier) {
1743
+ if (!guard) {
1744
+ return;
1745
+ }
1746
+ const isAllowed = await guard(args, context);
1747
+ if (!isAllowed) {
1748
+ throw new ToolAccessDeniedError(toolIdentifier, "Access denied by data access guard");
1749
+ }
1750
+ }
1751
+ async function resolveInvalidationTags(config, args, rawResult, context) {
1752
+ if (!config.invalidationTags) {
1753
+ return void 0;
1754
+ }
1755
+ const tags = typeof config.invalidationTags === "function" ? await config.invalidationTags(args, rawResult) : config.invalidationTags;
1756
+ if (tags && tags.length > 0 && context?.onInvalidationTags) {
1757
+ await context.onInvalidationTags(tags);
1758
+ }
1759
+ return tags;
1760
+ }
1761
+ async function dispatchClientData(rawResult, callback) {
1762
+ if (!callback) {
1763
+ return;
1764
+ }
1765
+ await callback(rawResult);
1766
+ }
1767
+ async function produceLlmPayload(rawResult, args, context, transformer) {
1768
+ if (transformer) {
1769
+ return await transformer(rawResult, args, context);
1770
+ }
1771
+ return rawResult;
1772
+ }
1773
+ function validateLlmDto(payload, schema, toolIdentifier) {
1774
+ const parseResult = schema.safeParse(payload);
1775
+ if (!parseResult.success) {
1776
+ const issues = parseResult.error.issues ?? [];
1777
+ const errorMessages = issues.map((issue) => `${issue.path.join(".") || "root"}: ${issue.message}`).join(", ");
1778
+ throw new DtoValidationError(
1779
+ toolIdentifier,
1780
+ errorMessages,
1781
+ issues
1782
+ );
1783
+ }
1784
+ return parseResult.data;
1785
+ }
1786
+ function protectLlmPayload(payload, toolIdentifier, sanitizePii = true, throwOnPii = false) {
1787
+ if (!sanitizePii) {
1788
+ return { sanitized: payload, count: 0 };
1789
+ }
1790
+ const { sanitizedData, maskedCount } = auditToolResult(payload, {
1791
+ toolName: toolIdentifier,
1792
+ throwOnPii
1793
+ });
1794
+ return { sanitized: sanitizedData, count: maskedCount };
1795
+ }
1796
+ async function processLlmPayload(rawResult, args, context, config, toolIdentifier) {
1797
+ let payload = await produceLlmPayload(rawResult, args, context, config.llmDto);
1798
+ if (config.llmDtoSchema) {
1799
+ payload = validateLlmDto(payload, config.llmDtoSchema, toolIdentifier);
1800
+ }
1801
+ return protectLlmPayload(
1802
+ payload,
1803
+ toolIdentifier,
1804
+ config.sanitizePii !== false,
1805
+ config.throwOnPii === true
1806
+ );
1807
+ }
1808
+ function createIsolatedTool(config) {
1809
+ const toolId = config.id || config.name;
1810
+ const toolAlias = config.alias;
1811
+ const clientCallback = config.clientDto;
1812
+ const toolIdentifier = toolAlias || config.name;
1813
+ const toolImpact = config.impact ?? "READ_ONLY";
1814
+ const requireApproval = config.requireApproval ?? toolImpact === "DESTRUCTIVE";
1815
+ const tool = {
1816
+ description: config.description,
1817
+ parameters: config.parameters,
1818
+ _toolId: toolId,
1819
+ _toolName: config.name,
1820
+ _toolAlias: toolAlias,
1821
+ _isIsolated: true,
1822
+ _cacheTTL: config.cacheTTL,
1823
+ _domain: config.domain,
1824
+ _resource: config.resource,
1825
+ _roles: config.roles ? Object.freeze([...config.roles]) : void 0,
1826
+ _impact: toolImpact,
1827
+ _requireApproval: requireApproval,
1828
+ _lastPiiFilteredCount: 0,
1829
+ _lastInvalidationTags: void 0,
1830
+ async execute(args, context) {
1831
+ const updatedContext = {
1832
+ ...context,
1833
+ callChain: context?.callChain ?? Object.freeze([toolId])
1834
+ };
1835
+ await verifyDataAccessGuard(
1836
+ config.dataAccessGuard,
1837
+ args,
1838
+ updatedContext,
1839
+ toolIdentifier
1840
+ );
1841
+ const rawResult = await config.execute(args, updatedContext);
1842
+ const tags = await resolveInvalidationTags(
1843
+ config,
1844
+ args,
1845
+ rawResult,
1846
+ updatedContext
1847
+ );
1848
+ if (tags) {
1849
+ tool._lastInvalidationTags = tags;
1850
+ }
1851
+ await dispatchClientData(rawResult, clientCallback);
1852
+ const protection = await processLlmPayload(
1853
+ rawResult,
1854
+ args,
1855
+ updatedContext,
1856
+ config,
1857
+ toolIdentifier
1858
+ );
1859
+ tool._lastPiiFilteredCount = protection.count;
1860
+ return protection.sanitized;
1861
+ }
1862
+ };
1863
+ return tool;
1864
+ }
1865
+
1866
+ // src/workflow/errors.ts
1867
+ var WorkflowSagaRollbackError = class extends Error {
1868
+ workflowId;
1869
+ failedStepId;
1870
+ originalError;
1871
+ compensatedSteps;
1872
+ failedCompensations;
1873
+ constructor(params) {
1874
+ const errorDetails = params.originalError instanceof Error ? params.originalError.message : String(params.originalError);
1875
+ super(
1876
+ `\xC9chec de l'\xE9tape '${params.failedStepId}' dans le workflow '${params.workflowId}'. Rollback Saga ex\xE9cut\xE9 sur [${params.compensatedSteps.join(", ")}]. Cause initiale: ${errorDetails}`
1877
+ );
1878
+ this.name = "WorkflowSagaRollbackError";
1879
+ this.workflowId = params.workflowId;
1880
+ this.failedStepId = params.failedStepId;
1881
+ this.originalError = params.originalError;
1882
+ this.compensatedSteps = params.compensatedSteps;
1883
+ this.failedCompensations = params.failedCompensations ?? [];
1884
+ }
1885
+ };
1886
+ var WorkflowValidationError = class extends Error {
1887
+ workflowId;
1888
+ issues;
1889
+ constructor(workflowId, issues) {
1890
+ super(`Validation des entr\xE9es \xE9chou\xE9e pour le workflow '${workflowId}'.`);
1891
+ this.name = "WorkflowValidationError";
1892
+ this.workflowId = workflowId;
1893
+ this.issues = issues;
1894
+ }
1895
+ };
1896
+
1897
+ // src/workflow/engine.ts
1898
+ function generateRunId(workflowId) {
1899
+ const timestamp = Date.now();
1900
+ const randomSuffix = Math.random().toString(36).substring(2, 9);
1901
+ return `run_${workflowId}_${timestamp}_${randomSuffix}`;
1902
+ }
1903
+ function validateInput(config, input) {
1904
+ const parseResult = config.inputSchema.safeParse(input);
1905
+ if (!parseResult.success) {
1906
+ throw new WorkflowValidationError(config.id, parseResult.error.issues);
1907
+ }
1908
+ return parseResult.data;
1909
+ }
1910
+ function createStepContext(params) {
1911
+ const { workflowId, stepId, runId, context, stepResults } = params;
1912
+ return {
1913
+ workflowId,
1914
+ stepId,
1915
+ runId,
1916
+ tenantId: context?.tenantId,
1917
+ userId: context?.userId,
1918
+ services: context?.services ?? {},
1919
+ storage: context?.storage,
1920
+ getStepResult: (id) => stepResults[id],
1921
+ waitForApproval: async (options) => {
1922
+ if (context?.storage) {
1923
+ const existing = await context.storage.getStep(workflowId, stepId);
1924
+ if (existing && existing.status === "COMPLETED") {
1925
+ return existing.result ?? options?.defaultResult;
1926
+ }
1927
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1928
+ await context.storage.saveStep({
1929
+ workflowId,
1930
+ stepId,
1931
+ runId,
1932
+ status: "WAITING_APPROVAL",
1933
+ metadata: options?.metadata,
1934
+ createdAt: now,
1935
+ updatedAt: now
1936
+ });
1937
+ }
1938
+ throw new StepSuspendedError(stepId, workflowId, options?.prompt);
1939
+ }
1940
+ };
1941
+ }
1942
+ async function rollbackSaga(params) {
1943
+ const {
1944
+ workflowId,
1945
+ failedStepId,
1946
+ originalError,
1947
+ completedSteps,
1948
+ input,
1949
+ runId,
1950
+ context,
1951
+ stepResults
1952
+ } = params;
1953
+ const compensatedSteps = [];
1954
+ const failedCompensations = [];
1955
+ for (let i = completedSteps.length - 1; i >= 0; i--) {
1956
+ const { step, result } = completedSteps[i];
1957
+ if (!step.compensate) {
1958
+ continue;
1959
+ }
1960
+ const stepCtx = createStepContext({
1961
+ workflowId,
1962
+ stepId: step.id,
1963
+ runId,
1964
+ context,
1965
+ stepResults
1966
+ });
1967
+ try {
1968
+ await step.compensate(result, input, stepCtx);
1969
+ compensatedSteps.push(step.id);
1970
+ if (context?.storage) {
1971
+ await context.storage.updateStepStatus(workflowId, step.id, "FAILED", {
1972
+ metadata: { compensated: true }
1973
+ });
1974
+ }
1975
+ } catch (compensationError) {
1976
+ failedCompensations.push({ stepId: step.id, error: compensationError });
1977
+ }
1978
+ }
1979
+ throw new WorkflowSagaRollbackError({
1980
+ workflowId,
1981
+ failedStepId,
1982
+ originalError,
1983
+ compensatedSteps,
1984
+ failedCompensations
1985
+ });
1986
+ }
1987
+ async function executeWorkflow(config, rawInput, context) {
1988
+ const input = validateInput(config, rawInput);
1989
+ const runId = context?.runId ?? generateRunId(config.id);
1990
+ const stepResults = {};
1991
+ const completedSteps = [];
1992
+ for (const step of config.steps) {
1993
+ const stepCtx = createStepContext({
1994
+ workflowId: config.id,
1995
+ stepId: step.id,
1996
+ runId,
1997
+ context,
1998
+ stepResults
1999
+ });
2000
+ try {
2001
+ const result = await step.execute(input, stepCtx);
2002
+ stepResults[step.id] = result;
2003
+ completedSteps.push({ step, result });
2004
+ if (context?.storage) {
2005
+ await context.storage.updateStepStatus(config.id, step.id, "COMPLETED", { result });
2006
+ }
2007
+ } catch (error) {
2008
+ if (error instanceof StepSuspendedError) {
2009
+ return {
2010
+ workflowId: config.id,
2011
+ runId,
2012
+ status: "WAITING_APPROVAL",
2013
+ stepResults
2014
+ };
2015
+ }
2016
+ await rollbackSaga({
2017
+ workflowId: config.id,
2018
+ failedStepId: step.id,
2019
+ originalError: error,
2020
+ completedSteps,
2021
+ input,
2022
+ runId,
2023
+ context,
2024
+ stepResults
2025
+ });
2026
+ }
2027
+ }
2028
+ const finalOutput = config.outputDto ? config.outputDto(stepResults, input) : stepResults;
2029
+ return {
2030
+ workflowId: config.id,
2031
+ runId,
2032
+ status: "COMPLETED",
2033
+ stepResults,
2034
+ output: finalOutput
2035
+ };
2036
+ }
2037
+
2038
+ // src/workflow/define-workflow.ts
2039
+ function resolveWorkflowImpact(config, options) {
2040
+ if (options?.impact) {
2041
+ return options.impact;
2042
+ }
2043
+ return config.impact ?? "MUTATIVE";
2044
+ }
2045
+ function resolveRequireApproval(impact, options) {
2046
+ if (options?.requireApproval !== void 0) {
2047
+ return options.requireApproval;
2048
+ }
2049
+ return impact === "DESTRUCTIVE";
2050
+ }
2051
+ function buildToolExecutionContext(options, toolCtx) {
2052
+ const tenantId = typeof toolCtx?.tenantId === "string" ? toolCtx.tenantId : options?.defaultContext?.tenantId;
2053
+ const userId = typeof toolCtx?.userId === "string" ? toolCtx.userId : options?.defaultContext?.userId;
2054
+ return {
2055
+ tenantId,
2056
+ userId,
2057
+ services: options?.defaultContext?.services ?? {},
2058
+ storage: options?.storage ?? options?.defaultContext?.storage
2059
+ };
2060
+ }
2061
+ function defineWorkflow(config) {
2062
+ const workflowImpact = config.impact ?? "MUTATIVE";
2063
+ return {
2064
+ id: config.id,
2065
+ name: config.name,
2066
+ description: config.description,
2067
+ impact: workflowImpact,
2068
+ roles: config.roles,
2069
+ config,
2070
+ execute: async (input, context) => {
2071
+ return await executeWorkflow(config, input, context);
2072
+ },
2073
+ asTool: (options) => {
2074
+ const impact = resolveWorkflowImpact(config, options);
2075
+ const requireApproval = resolveRequireApproval(impact, options);
2076
+ const tool = createIsolatedTool({
2077
+ name: config.id,
2078
+ description: config.description ?? config.name,
2079
+ roles: config.roles,
2080
+ impact,
2081
+ requireApproval,
2082
+ parameters: config.inputSchema,
2083
+ invalidationTags: typeof config.invalidationTags === "function" ? async (args, res) => {
2084
+ const resolver = config.invalidationTags;
2085
+ return await resolver(args, res ?? {});
2086
+ } : config.invalidationTags,
2087
+ execute: async (args, toolCtx) => {
2088
+ const executionContext = buildToolExecutionContext(options, toolCtx);
2089
+ const result = await executeWorkflow(config, args, executionContext);
2090
+ return result.output;
2091
+ },
2092
+ llmDto: (result) => result
2093
+ });
2094
+ Object.assign(tool, {
2095
+ _isWorkflow: true,
2096
+ workflowId: config.id,
2097
+ workflowConfig: {
2098
+ totalSteps: config.steps.length,
2099
+ impact
2100
+ }
2101
+ });
2102
+ return tool;
2103
+ }
2104
+ };
2105
+ }
1632
2106
  // Annotate the CommonJS export names for ESM import in node:
1633
2107
  0 && (module.exports = {
1634
2108
  AvantGateBudgetExceededError,
@@ -1644,11 +2118,15 @@ var PromptRegistry = class {
1644
2118
  PromptRegistry,
1645
2119
  PromptTemplate,
1646
2120
  SEED_MODEL_PRICES,
2121
+ WorkflowSagaRollbackError,
2122
+ WorkflowValidationError,
1647
2123
  ZenLLMControlLayer,
1648
2124
  calculateCostUSD,
1649
2125
  createAvantGate,
1650
2126
  createHttpProviderClient,
1651
2127
  createLLMControlLayer,
2128
+ defineWorkflow,
2129
+ executeWorkflow,
1652
2130
  extractAndCleanJSON,
1653
2131
  resolveModelPrice,
1654
2132
  resolveModelPriceAsync,
package/dist/index.mjs CHANGED
@@ -1,10 +1,16 @@
1
- import {
2
- sanitizePII
3
- } from "./chunk-DVCF4CSV.mjs";
4
1
  import {
5
2
  extractAndCleanJSON,
6
3
  validateWithZod
7
4
  } from "./chunk-CO26LNFD.mjs";
5
+ import {
6
+ WorkflowSagaRollbackError,
7
+ WorkflowValidationError,
8
+ defineWorkflow,
9
+ executeWorkflow
10
+ } from "./chunk-DTM2OLCG.mjs";
11
+ import {
12
+ sanitizePII
13
+ } from "./chunk-5VA3EKPJ.mjs";
8
14
 
9
15
  // src/types.ts
10
16
  var ConfigurationError = class extends Error {
@@ -1043,11 +1049,15 @@ export {
1043
1049
  PromptRegistry,
1044
1050
  PromptTemplate,
1045
1051
  SEED_MODEL_PRICES,
1052
+ WorkflowSagaRollbackError,
1053
+ WorkflowValidationError,
1046
1054
  AvantGateControlLayer as ZenLLMControlLayer,
1047
1055
  calculateCostUSD,
1048
1056
  createAvantGate,
1049
1057
  createHttpProviderClient,
1050
1058
  createLLMControlLayer,
1059
+ defineWorkflow,
1060
+ executeWorkflow,
1051
1061
  extractAndCleanJSON,
1052
1062
  resolveModelPrice,
1053
1063
  resolveModelPriceAsync,
@@ -0,0 +1,3 @@
1
+ import type { WorkflowConfig, WorkflowInstance } from "./types";
2
+ export declare function defineWorkflow<TInput = any, TOutput = any>(config: WorkflowConfig<TInput, TOutput>): WorkflowInstance<TInput, TOutput>;
3
+ //# sourceMappingURL=define-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-workflow.d.ts","sourceRoot":"","sources":["../../src/workflow/define-workflow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,cAAc,EAGd,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAmCjB,wBAAgB,cAAc,CAAC,MAAM,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,EACxD,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CA8DnC"}
@@ -0,0 +1,3 @@
1
+ import type { WorkflowConfig, WorkflowExecutionContext, WorkflowExecutionResult } from "./types";
2
+ export declare function executeWorkflow<TInput, TOutput>(config: WorkflowConfig<TInput, TOutput>, rawInput: TInput, context?: WorkflowExecutionContext): Promise<WorkflowExecutionResult<TOutput>>;
3
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/workflow/engine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EAGxB,MAAM,SAAS,CAAC;AAsHjB,wBAAsB,eAAe,CAAC,MAAM,EAAE,OAAO,EACnD,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAyD3C"}
@@ -0,0 +1,24 @@
1
+ export interface FailedCompensationRecord {
2
+ stepId: string;
3
+ error: unknown;
4
+ }
5
+ export declare class WorkflowSagaRollbackError extends Error {
6
+ readonly workflowId: string;
7
+ readonly failedStepId: string;
8
+ readonly originalError: unknown;
9
+ readonly compensatedSteps: string[];
10
+ readonly failedCompensations: FailedCompensationRecord[];
11
+ constructor(params: {
12
+ workflowId: string;
13
+ failedStepId: string;
14
+ originalError: unknown;
15
+ compensatedSteps: string[];
16
+ failedCompensations?: FailedCompensationRecord[];
17
+ });
18
+ }
19
+ export declare class WorkflowValidationError extends Error {
20
+ readonly workflowId: string;
21
+ readonly issues: unknown[];
22
+ constructor(workflowId: string, issues: unknown[]);
23
+ }
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/workflow/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,mBAAmB,EAAE,wBAAwB,EAAE,CAAC;gBAE7C,MAAM,EAAE;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,OAAO,CAAC;QACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC3B,mBAAmB,CAAC,EAAE,wBAAwB,EAAE,CAAC;KAClD;CAiBF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;gBAEf,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;CAMlD"}
@@ -0,0 +1,5 @@
1
+ export { defineWorkflow } from "./define-workflow";
2
+ export { executeWorkflow } from "./engine";
3
+ export { WorkflowSagaRollbackError, WorkflowValidationError, type FailedCompensationRecord, } from "./errors";
4
+ export type { WorkflowAsToolOptions, WorkflowConfig, WorkflowExecutionContext, WorkflowExecutionResult, WorkflowInstance, WorkflowStepConfig, WorkflowStepContext, } from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}