@backendkit-labs/agent-enterprise 0.3.2 → 0.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.
Files changed (144) hide show
  1. package/README.md +2 -0
  2. package/dist/__tests__/integration/EventPublisher.integration.test.d.ts +2 -0
  3. package/dist/__tests__/integration/EventPublisher.integration.test.d.ts.map +1 -0
  4. package/dist/__tests__/integration/EventPublisher.integration.test.js +122 -0
  5. package/dist/__tests__/integration/EventPublisher.integration.test.js.map +1 -0
  6. package/dist/__tests__/unit/ComplianceGate.test.d.ts +2 -0
  7. package/dist/__tests__/unit/ComplianceGate.test.d.ts.map +1 -0
  8. package/dist/__tests__/unit/ComplianceGate.test.js +271 -0
  9. package/dist/__tests__/unit/ComplianceGate.test.js.map +1 -0
  10. package/dist/__tests__/unit/EventPublisher.test.d.ts +2 -0
  11. package/dist/__tests__/unit/EventPublisher.test.d.ts.map +1 -0
  12. package/dist/__tests__/unit/EventPublisher.test.js +160 -0
  13. package/dist/__tests__/unit/EventPublisher.test.js.map +1 -0
  14. package/dist/__tests__/unit/FlowLoader.test.d.ts +2 -0
  15. package/dist/__tests__/unit/FlowLoader.test.d.ts.map +1 -0
  16. package/dist/__tests__/unit/FlowLoader.test.js +283 -0
  17. package/dist/__tests__/unit/FlowLoader.test.js.map +1 -0
  18. package/dist/__tests__/unit/FlowRunner.test.d.ts +2 -0
  19. package/dist/__tests__/unit/FlowRunner.test.d.ts.map +1 -0
  20. package/dist/__tests__/unit/FlowRunner.test.js +386 -0
  21. package/dist/__tests__/unit/FlowRunner.test.js.map +1 -0
  22. package/dist/__tests__/unit/PolicySeeder.test.d.ts +2 -0
  23. package/dist/__tests__/unit/PolicySeeder.test.d.ts.map +1 -0
  24. package/dist/__tests__/unit/PolicySeeder.test.js +146 -0
  25. package/dist/__tests__/unit/PolicySeeder.test.js.map +1 -0
  26. package/dist/__tests__/unit/ProfilePolicies.test.d.ts +2 -0
  27. package/dist/__tests__/unit/ProfilePolicies.test.d.ts.map +1 -0
  28. package/dist/__tests__/unit/ProfilePolicies.test.js +70 -0
  29. package/dist/__tests__/unit/ProfilePolicies.test.js.map +1 -0
  30. package/dist/__tests__/unit/ReconciliationSweeper.test.d.ts +2 -0
  31. package/dist/__tests__/unit/ReconciliationSweeper.test.d.ts.map +1 -0
  32. package/dist/__tests__/unit/ReconciliationSweeper.test.js +235 -0
  33. package/dist/__tests__/unit/ReconciliationSweeper.test.js.map +1 -0
  34. package/dist/__tests__/unit/n8nTriggerTool.test.d.ts +2 -0
  35. package/dist/__tests__/unit/n8nTriggerTool.test.d.ts.map +1 -0
  36. package/dist/__tests__/unit/n8nTriggerTool.test.js +103 -0
  37. package/dist/__tests__/unit/n8nTriggerTool.test.js.map +1 -0
  38. package/dist/events/EventPublisher.d.ts +47 -0
  39. package/dist/events/EventPublisher.d.ts.map +1 -0
  40. package/dist/events/EventPublisher.js +75 -0
  41. package/dist/events/EventPublisher.js.map +1 -0
  42. package/dist/events/ReconciliationSweeper.d.ts +37 -0
  43. package/dist/events/ReconciliationSweeper.d.ts.map +1 -0
  44. package/dist/events/ReconciliationSweeper.js +151 -0
  45. package/dist/events/ReconciliationSweeper.js.map +1 -0
  46. package/dist/events/index.d.ts +6 -0
  47. package/dist/events/index.d.ts.map +1 -0
  48. package/dist/events/index.js +8 -0
  49. package/dist/events/index.js.map +1 -0
  50. package/dist/events/types.d.ts +48 -0
  51. package/dist/events/types.d.ts.map +1 -0
  52. package/dist/events/types.js +3 -0
  53. package/dist/events/types.js.map +1 -0
  54. package/dist/factory.d.ts +6 -0
  55. package/dist/factory.d.ts.map +1 -1
  56. package/dist/factory.js +11 -5
  57. package/dist/factory.js.map +1 -1
  58. package/dist/flow/ComplianceGate.d.ts +90 -0
  59. package/dist/flow/ComplianceGate.d.ts.map +1 -0
  60. package/dist/flow/ComplianceGate.js +214 -0
  61. package/dist/flow/ComplianceGate.js.map +1 -0
  62. package/dist/flow/FlowLoader.d.ts +22 -0
  63. package/dist/flow/FlowLoader.d.ts.map +1 -0
  64. package/dist/flow/FlowLoader.js +170 -0
  65. package/dist/flow/FlowLoader.js.map +1 -0
  66. package/dist/flow/FlowRunner.d.ts +73 -0
  67. package/dist/flow/FlowRunner.d.ts.map +1 -0
  68. package/dist/flow/FlowRunner.js +162 -0
  69. package/dist/flow/FlowRunner.js.map +1 -0
  70. package/dist/flow/index.d.ts +8 -0
  71. package/dist/flow/index.d.ts.map +1 -0
  72. package/dist/flow/index.js +21 -0
  73. package/dist/flow/index.js.map +1 -0
  74. package/dist/flow/types.d.ts +306 -0
  75. package/dist/flow/types.d.ts.map +1 -0
  76. package/dist/flow/types.js +63 -0
  77. package/dist/flow/types.js.map +1 -0
  78. package/dist/index.d.ts +10 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +32 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/integrations/index.d.ts +3 -0
  83. package/dist/integrations/index.d.ts.map +1 -0
  84. package/dist/integrations/index.js +6 -0
  85. package/dist/integrations/index.js.map +1 -0
  86. package/dist/integrations/n8nTriggerTool.d.ts +12 -0
  87. package/dist/integrations/n8nTriggerTool.d.ts.map +1 -0
  88. package/dist/integrations/n8nTriggerTool.js +45 -0
  89. package/dist/integrations/n8nTriggerTool.js.map +1 -0
  90. package/dist/policies/PolicySeeder.d.ts +31 -0
  91. package/dist/policies/PolicySeeder.d.ts.map +1 -0
  92. package/dist/policies/PolicySeeder.js +270 -0
  93. package/dist/policies/PolicySeeder.js.map +1 -0
  94. package/dist/policies/index.d.ts +3 -0
  95. package/dist/policies/index.d.ts.map +1 -0
  96. package/dist/policies/index.js +6 -0
  97. package/dist/policies/index.js.map +1 -0
  98. package/dist/profiles/constants.d.ts +4 -0
  99. package/dist/profiles/constants.d.ts.map +1 -1
  100. package/dist/profiles/constants.js +4 -0
  101. package/dist/profiles/constants.js.map +1 -1
  102. package/dist/profiles/finance.d.ts.map +1 -1
  103. package/dist/profiles/finance.js +7 -8
  104. package/dist/profiles/finance.js.map +1 -1
  105. package/dist/profiles/general.d.ts.map +1 -1
  106. package/dist/profiles/general.js +1 -0
  107. package/dist/profiles/general.js.map +1 -1
  108. package/dist/profiles/hr.d.ts.map +1 -1
  109. package/dist/profiles/hr.js +6 -8
  110. package/dist/profiles/hr.js.map +1 -1
  111. package/dist/profiles/ops.d.ts.map +1 -1
  112. package/dist/profiles/ops.js +6 -10
  113. package/dist/profiles/ops.js.map +1 -1
  114. package/dist/profiles/sales.d.ts.map +1 -1
  115. package/dist/profiles/sales.js +3 -1
  116. package/dist/profiles/sales.js.map +1 -1
  117. package/dist/profiles/support.d.ts.map +1 -1
  118. package/dist/profiles/support.js +2 -4
  119. package/dist/profiles/support.js.map +1 -1
  120. package/dist/rag/OllamaEmbedder.d.ts +6 -0
  121. package/dist/rag/OllamaEmbedder.d.ts.map +1 -1
  122. package/dist/rag/OllamaEmbedder.js +75 -16
  123. package/dist/rag/OllamaEmbedder.js.map +1 -1
  124. package/dist/rag/VaultWriter.d.ts +3 -0
  125. package/dist/rag/VaultWriter.d.ts.map +1 -1
  126. package/dist/rag/VaultWriter.js +63 -17
  127. package/dist/rag/VaultWriter.js.map +1 -1
  128. package/dist/reflection/EnterpriseReflection.d.ts +108 -0
  129. package/dist/reflection/EnterpriseReflection.d.ts.map +1 -0
  130. package/dist/reflection/EnterpriseReflection.js +296 -0
  131. package/dist/reflection/EnterpriseReflection.js.map +1 -0
  132. package/dist/reflection/GateReflectionBridge.d.ts +21 -0
  133. package/dist/reflection/GateReflectionBridge.d.ts.map +1 -0
  134. package/dist/reflection/GateReflectionBridge.js +120 -0
  135. package/dist/reflection/GateReflectionBridge.js.map +1 -0
  136. package/dist/reflection/domains.d.ts +6 -0
  137. package/dist/reflection/domains.d.ts.map +1 -0
  138. package/dist/reflection/domains.js +176 -0
  139. package/dist/reflection/domains.js.map +1 -0
  140. package/dist/reflection/index.d.ts +6 -0
  141. package/dist/reflection/index.d.ts.map +1 -0
  142. package/dist/reflection/index.js +11 -0
  143. package/dist/reflection/index.js.map +1 -0
  144. package/package.json +6 -2
@@ -0,0 +1,22 @@
1
+ /**
2
+ * FlowLoader — parses and validates declarative flow YAML.
3
+ *
4
+ * Validation happens in two layers:
5
+ * 1. Structural (Zod): shapes, required fields, enums.
6
+ * 2. Semantic: duplicate step ids, unknown `after` references, dependency
7
+ * cycles, trigger coherence, compensation selectors, and the static
8
+ * half of the compliance rule — a gate evaluator can never be the
9
+ * step's own executor (evaluador ≠ ejecutor, ADR-3).
10
+ */
11
+ import { FlowDefinition } from './types';
12
+ export declare class FlowLoadError extends Error {
13
+ readonly issues: string[];
14
+ constructor(flowName: string, issues: string[]);
15
+ }
16
+ /** Parses a YAML string into a validated FlowDefinition. */
17
+ export declare function parseFlow(yamlContent: string): FlowDefinition;
18
+ /** Loads and validates a single flow file. */
19
+ export declare function loadFlow(filePath: string): Promise<FlowDefinition>;
20
+ /** Loads every `*.yaml` / `*.yml` in a directory. Throws on the first invalid flow. */
21
+ export declare function loadFlowsFromDir(dir: string): Promise<FlowDefinition[]>;
22
+ //# sourceMappingURL=FlowLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowLoader.d.ts","sourceRoot":"","sources":["../../src/flow/FlowLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,cAAc,EAAwB,MAAM,SAAS,CAAC;AAE/D,qBAAa,aAAc,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEd,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAKjD;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAsB7D;AAED,8CAA8C;AAC9C,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAGxE;AAED,uFAAuF;AACvF,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAU7E"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /**
3
+ * FlowLoader — parses and validates declarative flow YAML.
4
+ *
5
+ * Validation happens in two layers:
6
+ * 1. Structural (Zod): shapes, required fields, enums.
7
+ * 2. Semantic: duplicate step ids, unknown `after` references, dependency
8
+ * cycles, trigger coherence, compensation selectors, and the static
9
+ * half of the compliance rule — a gate evaluator can never be the
10
+ * step's own executor (evaluador ≠ ejecutor, ADR-3).
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.FlowLoadError = void 0;
47
+ exports.parseFlow = parseFlow;
48
+ exports.loadFlow = loadFlow;
49
+ exports.loadFlowsFromDir = loadFlowsFromDir;
50
+ const fs = __importStar(require("fs/promises"));
51
+ const path = __importStar(require("path"));
52
+ const yaml = __importStar(require("yaml"));
53
+ const types_1 = require("./types");
54
+ class FlowLoadError extends Error {
55
+ issues;
56
+ constructor(flowName, issues) {
57
+ super(`Invalid flow "${flowName}":\n${issues.map(i => ` - ${i}`).join('\n')}`);
58
+ this.name = 'FlowLoadError';
59
+ this.issues = issues;
60
+ }
61
+ }
62
+ exports.FlowLoadError = FlowLoadError;
63
+ /** Parses a YAML string into a validated FlowDefinition. */
64
+ function parseFlow(yamlContent) {
65
+ let raw;
66
+ try {
67
+ raw = yaml.parse(yamlContent);
68
+ }
69
+ catch (err) {
70
+ throw new FlowLoadError('<unparsed>', [`YAML syntax error: ${err.message}`]);
71
+ }
72
+ const parsed = types_1.FlowDefinitionSchema.safeParse(raw);
73
+ if (!parsed.success) {
74
+ const name = raw?.flow;
75
+ throw new FlowLoadError(typeof name === 'string' ? name : '<unknown>', parsed.error.issues.map(i => `${i.path.join('.')}: ${i.message}`));
76
+ }
77
+ const def = parsed.data;
78
+ const issues = validateSemantics(def);
79
+ if (issues.length > 0)
80
+ throw new FlowLoadError(def.flow, issues);
81
+ return def;
82
+ }
83
+ /** Loads and validates a single flow file. */
84
+ async function loadFlow(filePath) {
85
+ const content = await fs.readFile(filePath, 'utf-8');
86
+ return parseFlow(content);
87
+ }
88
+ /** Loads every `*.yaml` / `*.yml` in a directory. Throws on the first invalid flow. */
89
+ async function loadFlowsFromDir(dir) {
90
+ const entries = await fs.readdir(dir);
91
+ const files = entries
92
+ .filter(f => f.endsWith('.yaml') || f.endsWith('.yml'))
93
+ .sort();
94
+ const flows = [];
95
+ for (const file of files) {
96
+ flows.push(await loadFlow(path.join(dir, file)));
97
+ }
98
+ return flows;
99
+ }
100
+ // ── Semantic validation ───────────────────────────────────────────────────────
101
+ function validateSemantics(def) {
102
+ const issues = [];
103
+ const ids = new Set();
104
+ for (const step of def.steps) {
105
+ if (ids.has(step.id))
106
+ issues.push(`duplicate step id "${step.id}"`);
107
+ ids.add(step.id);
108
+ }
109
+ for (const step of def.steps) {
110
+ for (const dep of step.after) {
111
+ if (!ids.has(dep)) {
112
+ issues.push(`step "${step.id}" references unknown step "${dep}" in after`);
113
+ }
114
+ if (dep === step.id) {
115
+ issues.push(`step "${step.id}" cannot depend on itself`);
116
+ }
117
+ }
118
+ if (step.gate?.evaluator && step.gate.evaluator === step.agent) {
119
+ issues.push(`step "${step.id}": gate evaluator "${step.gate.evaluator}" must differ from the executing agent (evaluador ≠ ejecutor)`);
120
+ }
121
+ }
122
+ issues.push(...detectCycles(def));
123
+ issues.push(...validateTrigger(def));
124
+ for (const comp of def.compensation) {
125
+ const stepId = comp.on.replace(/\.failed$/, '');
126
+ if (!ids.has(stepId)) {
127
+ issues.push(`compensation "on: ${comp.on}" references unknown step "${stepId}"`);
128
+ }
129
+ }
130
+ return issues;
131
+ }
132
+ function detectCycles(def) {
133
+ const depMap = new Map(def.steps.map(s => [s.id, s.after]));
134
+ const visited = new Set();
135
+ const inStack = new Set();
136
+ const issues = [];
137
+ const dfs = (id) => {
138
+ if (inStack.has(id)) {
139
+ issues.push(`dependency cycle detected at step "${id}"`);
140
+ return;
141
+ }
142
+ if (visited.has(id))
143
+ return;
144
+ inStack.add(id);
145
+ for (const dep of depMap.get(id) ?? [])
146
+ dfs(dep);
147
+ inStack.delete(id);
148
+ visited.add(id);
149
+ };
150
+ for (const step of def.steps) {
151
+ if (issues.length > 0)
152
+ break;
153
+ dfs(step.id);
154
+ }
155
+ return issues;
156
+ }
157
+ function validateTrigger(def) {
158
+ const t = def.trigger;
159
+ switch (t.type) {
160
+ case 'queue':
161
+ return t.queue ? [] : ['trigger type "queue" requires a queue name'];
162
+ case 'webhook':
163
+ return t.path ? [] : ['trigger type "webhook" requires a path'];
164
+ case 'cron':
165
+ return t.schedule ? [] : ['trigger type "cron" requires a schedule'];
166
+ case 'manual':
167
+ return [];
168
+ }
169
+ }
170
+ //# sourceMappingURL=FlowLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowLoader.js","sourceRoot":"","sources":["../../src/flow/FlowLoader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBH,8BAsBC;AAGD,4BAGC;AAGD,4CAUC;AAzDD,gDAAkC;AAClC,2CAA6B;AAC7B,2CAA6B;AAC7B,mCAA+D;AAE/D,MAAa,aAAc,SAAQ,KAAK;IAC3B,MAAM,CAAW;IAE1B,YAAY,QAAgB,EAAE,MAAgB;QAC1C,KAAK,CAAC,iBAAiB,QAAQ,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AARD,sCAQC;AAED,4DAA4D;AAC5D,SAAgB,SAAS,CAAC,WAAmB;IACzC,IAAI,GAAY,CAAC;IACjB,IAAI,CAAC;QACD,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,IAAI,aAAa,CAAC,YAAY,EAAE,CAAC,sBAAuB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,MAAM,GAAG,4BAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,GAAI,GAA+B,EAAE,IAAI,CAAC;QACpD,MAAM,IAAI,aAAa,CACnB,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,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AAC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM;QAC7B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,GAAmB;IACxC,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACtB,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACR,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC;QACzE,KAAK,SAAS;YACV,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC;QACpE,KAAK,MAAM;YACP,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC;QACzE,KAAK,QAAQ;YACT,OAAO,EAAE,CAAC;IAClB,CAAC;AACL,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * FlowRunner — executes a FlowDefinition on top of the core WorkflowRunner.
3
+ *
4
+ * Adds on top of core:
5
+ * - `{{payload}}` / `{{payload.path.to.field}}` interpolation into prompts
6
+ * - append-only transition log (every state change produces a FlowTransition)
7
+ * - compensation steps that run when their `on: <stepId>.failed` selector matches
8
+ * - gate `approval: human` mapped to core's requireApproval mechanism
9
+ *
10
+ * Gate criteria/evaluator enforcement arrives with ComplianceGate (fase 2);
11
+ * here they are carried through and exposed to the approval callback.
12
+ */
13
+ import type { Transport } from '@backendkit-labs/agent-core';
14
+ import { FlowDefinition, FlowStep, FlowResult, FlowTransition } from './types';
15
+ import { ComplianceGate } from './ComplianceGate';
16
+ import type { EnterpriseReflection } from '../reflection/index.js';
17
+ export type FlowAgentRunner = (agentId: string, input: string, context?: string, stepId?: string) => Promise<{
18
+ content: string;
19
+ }>;
20
+ export interface FlowRunOptions {
21
+ /** Trigger payload, interpolated into step prompts. */
22
+ payload?: unknown;
23
+ runAgent: FlowAgentRunner;
24
+ transport: Transport;
25
+ /**
26
+ * Called for steps with `gate.approval: human`. Receives the flow step
27
+ * (including its gate definition) and the outputs of its dependencies.
28
+ * Return false to reject the step and abort dependents.
29
+ */
30
+ onApprovalRequired?: (step: FlowStep, previousOutputs: Record<string, string>) => Promise<boolean>;
31
+ /**
32
+ * Called after a step executes successfully when the step has a gate with
33
+ * `criteria` defined. Receives the pre-built `ComplianceGate` (already
34
+ * configured with executor, evidenceMode, and criteria from the YAML), the
35
+ * flow step, and the step's output.
36
+ *
37
+ * The callback must evaluate each criterion via `gate.evaluateCriterion()`.
38
+ * When it returns, `gate.verdict` is checked:
39
+ * - `'passed'` → step proceeds
40
+ * - anything else → step is marked failed
41
+ *
42
+ * If omitted, the gate is auto-passed (same default as `onApprovalRequired`).
43
+ */
44
+ onGateRequired?: (gate: ComplianceGate, step: FlowStep, stepOutput: string) => Promise<void>;
45
+ /** Observer for the append-only transition log. */
46
+ onTransition?: (transition: FlowTransition) => void;
47
+ /**
48
+ * Cable 1: enterprise reflection adapter.
49
+ * When set, every ComplianceGate outcome (pass AND fail) is recorded in the
50
+ * failure catalog so recurring failures can be promoted to deterministic rules.
51
+ */
52
+ reflection?: EnterpriseReflection;
53
+ /**
54
+ * Stable identifier for this run. Used in gate records persisted to the vault.
55
+ * Auto-generated when not provided.
56
+ */
57
+ runId?: string;
58
+ }
59
+ export declare class FlowRunner {
60
+ private readonly def;
61
+ private readonly opts;
62
+ private readonly transitions;
63
+ constructor(def: FlowDefinition, opts: FlowRunOptions);
64
+ run(): Promise<FlowResult>;
65
+ private runCompensations;
66
+ private record;
67
+ }
68
+ /**
69
+ * Replaces `{{payload}}` and `{{payload.a.b}}` with values from the payload.
70
+ * Objects are JSON-stringified; missing paths render as `null`.
71
+ */
72
+ export declare function interpolate(template: string, payload: unknown): string;
73
+ //# sourceMappingURL=FlowRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowRunner.d.ts","sourceRoot":"","sources":["../../src/flow/FlowRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACH,cAAc,EACd,QAAQ,EACR,UAAU,EAEV,cAAc,EAEjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG,CAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElC,MAAM,WAAW,cAAc;IAC3B,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CACjB,IAAI,EAAE,QAAQ,EACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,CACb,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,KACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,mDAAmD;IACnD,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD;;;;OAIG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,UAAU;IAIf,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;gBAG/B,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc;IAGnC,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;YA4GlB,gBAAgB;IA6B9B,OAAO,CAAC,MAAM;CAKjB;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAWtE"}
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ /**
3
+ * FlowRunner — executes a FlowDefinition on top of the core WorkflowRunner.
4
+ *
5
+ * Adds on top of core:
6
+ * - `{{payload}}` / `{{payload.path.to.field}}` interpolation into prompts
7
+ * - append-only transition log (every state change produces a FlowTransition)
8
+ * - compensation steps that run when their `on: <stepId>.failed` selector matches
9
+ * - gate `approval: human` mapped to core's requireApproval mechanism
10
+ *
11
+ * Gate criteria/evaluator enforcement arrives with ComplianceGate (fase 2);
12
+ * here they are carried through and exposed to the approval callback.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FlowRunner = void 0;
16
+ exports.interpolate = interpolate;
17
+ const agent_core_1 = require("@backendkit-labs/agent-core");
18
+ const ComplianceGate_1 = require("./ComplianceGate");
19
+ class FlowRunner {
20
+ def;
21
+ opts;
22
+ transitions = [];
23
+ constructor(def, opts) {
24
+ this.def = def;
25
+ this.opts = opts;
26
+ }
27
+ async run() {
28
+ const stepsById = new Map(this.def.steps.map(s => [s.id, s]));
29
+ const runId = this.opts.runId ?? `run-${Date.now()}`;
30
+ // ── Build the core workflow with interpolated prompts ────────────────
31
+ const builder = new agent_core_1.WorkflowBuilder(this.def.flow);
32
+ for (const step of this.def.steps) {
33
+ builder.step(step.id, (0, agent_core_1.agent)(step.agent), {
34
+ input: interpolate(step.prompt, this.opts.payload),
35
+ dependsOn: step.after,
36
+ requireApproval: step.gate?.approval === 'human',
37
+ });
38
+ }
39
+ const runner = new agent_core_1.WorkflowRunner(builder.build(), {
40
+ transport: this.opts.transport,
41
+ runAgent: async (agentId, input, context, stepId) => {
42
+ this.record({ stepId: stepId ?? '?', event: 'started' });
43
+ try {
44
+ const result = await this.opts.runAgent(agentId, input, context, stepId);
45
+ // ── ComplianceGate evaluation ────────────────────────────
46
+ const flowStep = stepsById.get(stepId);
47
+ const gate = flowStep?.gate;
48
+ if (gate?.criteria?.length && gate.evaluator && this.opts.onGateRequired) {
49
+ this.record({ stepId: stepId, event: 'gate_evaluation_started' });
50
+ const complianceGate = new ComplianceGate_1.ComplianceGate({
51
+ stepId: stepId,
52
+ flowId: this.def.flow,
53
+ runId,
54
+ executor: agentId,
55
+ criteria: gate.criteria,
56
+ evidenceMode: gate.evidence ?? 'optional',
57
+ });
58
+ await this.opts.onGateRequired(complianceGate, flowStep, result.content);
59
+ // ── Cable 1: record outcome in enterprise reflection ───
60
+ // Fires for BOTH pass and fail — failures feed the catalog,
61
+ // passes build the "no incidents" signal used by demotion.
62
+ if (this.opts.reflection) {
63
+ this.opts.reflection
64
+ .recordGateOutcome(complianceGate.getRecord())
65
+ .catch(() => { });
66
+ }
67
+ // ──────────────────────────────────────────────────────
68
+ if (complianceGate.verdict !== 'passed') {
69
+ this.record({
70
+ stepId: stepId,
71
+ event: 'gate_failed',
72
+ detail: `verdict: ${complianceGate.verdict}`,
73
+ });
74
+ throw new ComplianceGate_1.ComplianceGateError(`gate for step "${stepId}" did not pass — verdict: ${complianceGate.verdict}`);
75
+ }
76
+ this.record({ stepId: stepId, event: 'gate_passed' });
77
+ }
78
+ // ────────────────────────────────────────────────────────
79
+ this.record({ stepId: stepId ?? '?', event: 'completed' });
80
+ return result;
81
+ }
82
+ catch (err) {
83
+ this.record({
84
+ stepId: stepId ?? '?',
85
+ event: 'failed',
86
+ detail: err instanceof Error ? err.message : String(err),
87
+ });
88
+ throw err;
89
+ }
90
+ },
91
+ onApprovalRequired: async (coreStep, previousOutputs) => {
92
+ this.record({ stepId: coreStep.id, event: 'approval_requested' });
93
+ const flowStep = stepsById.get(coreStep.id);
94
+ const approved = await (this.opts.onApprovalRequired?.(flowStep, previousOutputs) ?? Promise.resolve(true));
95
+ if (!approved) {
96
+ this.record({ stepId: coreStep.id, event: 'rejected' });
97
+ }
98
+ return approved;
99
+ },
100
+ });
101
+ const workflowResult = await runner.run();
102
+ // ── Record terminal states the runner doesn't surface via callbacks ──
103
+ for (const result of Object.values(workflowResult.steps)) {
104
+ if (result.status === 'skipped') {
105
+ this.record({ stepId: result.stepId, event: 'skipped' });
106
+ }
107
+ }
108
+ // ── Compensation for failed steps ─────────────────────────────────────
109
+ const compensations = await this.runCompensations(workflowResult.steps);
110
+ return {
111
+ flow: this.def.flow,
112
+ version: this.def.version,
113
+ status: workflowResult.status,
114
+ steps: workflowResult.steps,
115
+ transitions: [...this.transitions],
116
+ compensations,
117
+ };
118
+ }
119
+ // ── Private ───────────────────────────────────────────────────────────────
120
+ async runCompensations(steps) {
121
+ const results = [];
122
+ for (const comp of this.def.compensation) {
123
+ const stepId = comp.on.replace(/\.failed$/, '');
124
+ if (steps[stepId]?.status !== 'failed')
125
+ continue;
126
+ this.record({ stepId, event: 'compensation_started', detail: `agent: ${comp.agent}` });
127
+ try {
128
+ const { content } = await this.opts.runAgent(comp.agent, interpolate(comp.prompt, this.opts.payload), `Failed step "${stepId}": ${steps[stepId].error ?? 'unknown error'}`, `${stepId}:compensation`);
129
+ results.push({ on: comp.on, agent: comp.agent, status: 'completed', content });
130
+ this.record({ stepId, event: 'compensation_completed' });
131
+ }
132
+ catch (err) {
133
+ const error = err instanceof Error ? err.message : String(err);
134
+ results.push({ on: comp.on, agent: comp.agent, status: 'failed', error });
135
+ this.record({ stepId, event: 'compensation_failed', detail: error });
136
+ }
137
+ }
138
+ return results;
139
+ }
140
+ record(t) {
141
+ const transition = { at: new Date().toISOString(), ...t };
142
+ this.transitions.push(transition);
143
+ this.opts.onTransition?.(transition);
144
+ }
145
+ }
146
+ exports.FlowRunner = FlowRunner;
147
+ // ── Interpolation ─────────────────────────────────────────────────────────────
148
+ /**
149
+ * Replaces `{{payload}}` and `{{payload.a.b}}` with values from the payload.
150
+ * Objects are JSON-stringified; missing paths render as `null`.
151
+ */
152
+ function interpolate(template, payload) {
153
+ return template.replace(/\{\{\s*payload((?:\.[\w-]+)*)\s*\}\}/g, (_match, pathStr) => {
154
+ const value = pathStr
155
+ ? pathStr.slice(1).split('.').reduce((acc, key) => acc?.[key], payload)
156
+ : payload;
157
+ if (value === undefined || value === null)
158
+ return 'null';
159
+ return typeof value === 'string' ? value : JSON.stringify(value);
160
+ });
161
+ }
162
+ //# sourceMappingURL=FlowRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowRunner.js","sourceRoot":"","sources":["../../src/flow/FlowRunner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAuOH,kCAWC;AAhPD,4DAIqC;AAUrC,qDAAuE;AAyDvE,MAAa,UAAU;IAIE;IACA;IAJJ,WAAW,GAAqB,EAAE,CAAC;IAEpD,YACqB,GAAmB,EACnB,IAAoB;QADpB,QAAG,GAAH,GAAG,CAAgB;QACnB,SAAI,GAAJ,IAAI,CAAgB;IACtC,CAAC;IAEJ,KAAK,CAAC,GAAG;QACL,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAErD,wEAAwE;Q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AE,OAAe,EAAE,EAAE;QACzF,MAAM,KAAK,GAAG,OAAO;YACjB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAChC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAE,GAA2C,EAAE,CAAC,GAAG,CAAC,EACjE,OAAO,CACR;YACH,CAAC,CAAC,OAAO,CAAC;QACd,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;QACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { FlowTriggerSchema, FlowGateSchema, FlowStepSchema, FlowCompensationSchema, FlowDefinitionSchema, } from './types';
2
+ export type { FlowTrigger, FlowGate, FlowStep, FlowCompensation, FlowDefinition, FlowTransition, FlowTransitionEvent, FlowStepResult, FlowCompensationResult, FlowResult, } from './types';
3
+ export { parseFlow, loadFlow, loadFlowsFromDir, FlowLoadError } from './FlowLoader';
4
+ export { FlowRunner, interpolate } from './FlowRunner';
5
+ export type { FlowRunOptions, FlowAgentRunner } from './FlowRunner';
6
+ export { ComplianceGate, ComplianceGateError } from './ComplianceGate';
7
+ export type { GateCriterion, GateLogEvent, GateLogEntry, GateRecord, ComplianceGateOptions, } from './ComplianceGate';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACvB,MAAM,SAAS,CAAC;AACjB,YAAY,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,UAAU,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EACR,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,GACxB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComplianceGateError = exports.ComplianceGate = exports.interpolate = exports.FlowRunner = exports.FlowLoadError = exports.loadFlowsFromDir = exports.loadFlow = exports.parseFlow = exports.FlowDefinitionSchema = exports.FlowCompensationSchema = exports.FlowStepSchema = exports.FlowGateSchema = exports.FlowTriggerSchema = void 0;
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "FlowTriggerSchema", { enumerable: true, get: function () { return types_1.FlowTriggerSchema; } });
6
+ Object.defineProperty(exports, "FlowGateSchema", { enumerable: true, get: function () { return types_1.FlowGateSchema; } });
7
+ Object.defineProperty(exports, "FlowStepSchema", { enumerable: true, get: function () { return types_1.FlowStepSchema; } });
8
+ Object.defineProperty(exports, "FlowCompensationSchema", { enumerable: true, get: function () { return types_1.FlowCompensationSchema; } });
9
+ Object.defineProperty(exports, "FlowDefinitionSchema", { enumerable: true, get: function () { return types_1.FlowDefinitionSchema; } });
10
+ var FlowLoader_1 = require("./FlowLoader");
11
+ Object.defineProperty(exports, "parseFlow", { enumerable: true, get: function () { return FlowLoader_1.parseFlow; } });
12
+ Object.defineProperty(exports, "loadFlow", { enumerable: true, get: function () { return FlowLoader_1.loadFlow; } });
13
+ Object.defineProperty(exports, "loadFlowsFromDir", { enumerable: true, get: function () { return FlowLoader_1.loadFlowsFromDir; } });
14
+ Object.defineProperty(exports, "FlowLoadError", { enumerable: true, get: function () { return FlowLoader_1.FlowLoadError; } });
15
+ var FlowRunner_1 = require("./FlowRunner");
16
+ Object.defineProperty(exports, "FlowRunner", { enumerable: true, get: function () { return FlowRunner_1.FlowRunner; } });
17
+ Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return FlowRunner_1.interpolate; } });
18
+ var ComplianceGate_1 = require("./ComplianceGate");
19
+ Object.defineProperty(exports, "ComplianceGate", { enumerable: true, get: function () { return ComplianceGate_1.ComplianceGate; } });
20
+ Object.defineProperty(exports, "ComplianceGateError", { enumerable: true, get: function () { return ComplianceGate_1.ComplianceGateError; } });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":";;;AAAA,iCAMiB;AALb,0GAAA,iBAAiB,OAAA;AACjB,uGAAA,cAAc,OAAA;AACd,uGAAA,cAAc,OAAA;AACd,+GAAA,sBAAsB,OAAA;AACtB,6GAAA,oBAAoB,OAAA;AAexB,2CAAoF;AAA3E,uGAAA,SAAS,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,2GAAA,aAAa,OAAA;AAC7D,2CAAuD;AAA9C,wGAAA,UAAU,OAAA;AAAE,yGAAA,WAAW,OAAA;AAGhC,mDAAuE;AAA9D,gHAAA,cAAc,OAAA;AAAE,qHAAA,mBAAmB,OAAA"}