@backendkit-labs/agent-enterprise 0.3.1 → 0.3.6
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/README.md +2 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.js +122 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.js.map +1 -0
- package/dist/__tests__/unit/ComplianceGate.test.d.ts +2 -0
- package/dist/__tests__/unit/ComplianceGate.test.d.ts.map +1 -0
- package/dist/__tests__/unit/ComplianceGate.test.js +271 -0
- package/dist/__tests__/unit/ComplianceGate.test.js.map +1 -0
- package/dist/__tests__/unit/EventPublisher.test.d.ts +2 -0
- package/dist/__tests__/unit/EventPublisher.test.d.ts.map +1 -0
- package/dist/__tests__/unit/EventPublisher.test.js +160 -0
- package/dist/__tests__/unit/EventPublisher.test.js.map +1 -0
- package/dist/__tests__/unit/FlowLoader.test.d.ts +2 -0
- package/dist/__tests__/unit/FlowLoader.test.d.ts.map +1 -0
- package/dist/__tests__/unit/FlowLoader.test.js +283 -0
- package/dist/__tests__/unit/FlowLoader.test.js.map +1 -0
- package/dist/__tests__/unit/FlowRunner.test.d.ts +2 -0
- package/dist/__tests__/unit/FlowRunner.test.d.ts.map +1 -0
- package/dist/__tests__/unit/FlowRunner.test.js +386 -0
- package/dist/__tests__/unit/FlowRunner.test.js.map +1 -0
- package/dist/__tests__/unit/PolicySeeder.test.d.ts +2 -0
- package/dist/__tests__/unit/PolicySeeder.test.d.ts.map +1 -0
- package/dist/__tests__/unit/PolicySeeder.test.js +146 -0
- package/dist/__tests__/unit/PolicySeeder.test.js.map +1 -0
- package/dist/__tests__/unit/ProfilePolicies.test.d.ts +2 -0
- package/dist/__tests__/unit/ProfilePolicies.test.d.ts.map +1 -0
- package/dist/__tests__/unit/ProfilePolicies.test.js +70 -0
- package/dist/__tests__/unit/ProfilePolicies.test.js.map +1 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.d.ts +2 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.d.ts.map +1 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.js +235 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.js.map +1 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.d.ts +2 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.d.ts.map +1 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.js +103 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.js.map +1 -0
- package/dist/events/EventPublisher.d.ts +47 -0
- package/dist/events/EventPublisher.d.ts.map +1 -0
- package/dist/events/EventPublisher.js +75 -0
- package/dist/events/EventPublisher.js.map +1 -0
- package/dist/events/ReconciliationSweeper.d.ts +37 -0
- package/dist/events/ReconciliationSweeper.d.ts.map +1 -0
- package/dist/events/ReconciliationSweeper.js +151 -0
- package/dist/events/ReconciliationSweeper.js.map +1 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +8 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +48 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +3 -0
- package/dist/events/types.js.map +1 -0
- package/dist/factory.d.ts +6 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +11 -5
- package/dist/factory.js.map +1 -1
- package/dist/flow/ComplianceGate.d.ts +80 -0
- package/dist/flow/ComplianceGate.d.ts.map +1 -0
- package/dist/flow/ComplianceGate.js +214 -0
- package/dist/flow/ComplianceGate.js.map +1 -0
- package/dist/flow/FlowLoader.d.ts +22 -0
- package/dist/flow/FlowLoader.d.ts.map +1 -0
- package/dist/flow/FlowLoader.js +170 -0
- package/dist/flow/FlowLoader.js.map +1 -0
- package/dist/flow/FlowRunner.d.ts +66 -0
- package/dist/flow/FlowRunner.d.ts.map +1 -0
- package/dist/flow/FlowRunner.js +153 -0
- package/dist/flow/FlowRunner.js.map +1 -0
- package/dist/flow/index.d.ts +8 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +21 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/types.d.ts +306 -0
- package/dist/flow/types.d.ts.map +1 -0
- package/dist/flow/types.js +63 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +6 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/n8nTriggerTool.d.ts +12 -0
- package/dist/integrations/n8nTriggerTool.d.ts.map +1 -0
- package/dist/integrations/n8nTriggerTool.js +45 -0
- package/dist/integrations/n8nTriggerTool.js.map +1 -0
- package/dist/policies/PolicySeeder.d.ts +31 -0
- package/dist/policies/PolicySeeder.d.ts.map +1 -0
- package/dist/policies/PolicySeeder.js +270 -0
- package/dist/policies/PolicySeeder.js.map +1 -0
- package/dist/policies/index.d.ts +3 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +6 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/profiles/constants.d.ts +4 -0
- package/dist/profiles/constants.d.ts.map +1 -1
- package/dist/profiles/constants.js +4 -0
- package/dist/profiles/constants.js.map +1 -1
- package/dist/profiles/finance.d.ts.map +1 -1
- package/dist/profiles/finance.js +7 -8
- package/dist/profiles/finance.js.map +1 -1
- package/dist/profiles/general.d.ts.map +1 -1
- package/dist/profiles/general.js +1 -0
- package/dist/profiles/general.js.map +1 -1
- package/dist/profiles/hr.d.ts.map +1 -1
- package/dist/profiles/hr.js +6 -8
- package/dist/profiles/hr.js.map +1 -1
- package/dist/profiles/ops.d.ts.map +1 -1
- package/dist/profiles/ops.js +6 -10
- package/dist/profiles/ops.js.map +1 -1
- package/dist/profiles/sales.d.ts.map +1 -1
- package/dist/profiles/sales.js +3 -1
- package/dist/profiles/sales.js.map +1 -1
- package/dist/profiles/support.d.ts.map +1 -1
- package/dist/profiles/support.js +2 -4
- package/dist/profiles/support.js.map +1 -1
- package/dist/rag/ObsidianRAGProvider.js +4 -4
- package/dist/rag/ObsidianRAGProvider.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative flow definitions — business flows as data, not code.
|
|
3
|
+
*
|
|
4
|
+
* A FlowDefinition is loaded from YAML, validated, and executed on top of
|
|
5
|
+
* the core WorkflowRunner. Adding a new business flow for a company means
|
|
6
|
+
* writing a YAML file — zero platform code.
|
|
7
|
+
*
|
|
8
|
+
* Gate semantics (criteria/evaluator/evidence) are parsed and carried here
|
|
9
|
+
* so the YAML format is stable; their enforcement lands with ComplianceGate
|
|
10
|
+
* (design doc: diseno-multiagente-enterprise.md, fase 2).
|
|
11
|
+
*/
|
|
12
|
+
import { z } from '@backendkit-labs/agent-core';
|
|
13
|
+
export declare const FlowTriggerSchema: z.ZodObject<{
|
|
14
|
+
/** How the flow is started. `manual` = invoked programmatically. */
|
|
15
|
+
type: z.ZodEnum<["queue", "webhook", "cron", "manual"]>;
|
|
16
|
+
/** Queue name — required when type is `queue`. */
|
|
17
|
+
queue: z.ZodOptional<z.ZodString>;
|
|
18
|
+
/** Route path — required when type is `webhook`. */
|
|
19
|
+
path: z.ZodOptional<z.ZodString>;
|
|
20
|
+
/** Cron expression — required when type is `cron`. */
|
|
21
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
type: "queue" | "webhook" | "cron" | "manual";
|
|
24
|
+
path?: string | undefined;
|
|
25
|
+
queue?: string | undefined;
|
|
26
|
+
schedule?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
type: "queue" | "webhook" | "cron" | "manual";
|
|
29
|
+
path?: string | undefined;
|
|
30
|
+
queue?: string | undefined;
|
|
31
|
+
schedule?: string | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const FlowGateSchema: z.ZodObject<{
|
|
34
|
+
/** Verifiable completion criteria, evaluated one by one (ComplianceGate). */
|
|
35
|
+
criteria: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
36
|
+
/** Agent that evaluates the criteria. MUST differ from the executing agent. */
|
|
37
|
+
evaluator: z.ZodOptional<z.ZodString>;
|
|
38
|
+
/** Whether each criterion requires attached evidence to pass. */
|
|
39
|
+
evidence: z.ZodDefault<z.ZodEnum<["required", "optional"]>>;
|
|
40
|
+
/** `human` pauses the step until a human approves (core ApprovalGate). */
|
|
41
|
+
approval: z.ZodDefault<z.ZodEnum<["human", "none"]>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
criteria: string[];
|
|
44
|
+
evidence: "required" | "optional";
|
|
45
|
+
approval: "human" | "none";
|
|
46
|
+
evaluator?: string | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
criteria?: string[] | undefined;
|
|
49
|
+
evaluator?: string | undefined;
|
|
50
|
+
evidence?: "required" | "optional" | undefined;
|
|
51
|
+
approval?: "human" | "none" | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const FlowStepSchema: z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
/** Agent id that executes this step. */
|
|
56
|
+
agent: z.ZodString;
|
|
57
|
+
/** Prompt for the agent. Supports `{{payload}}` and `{{payload.path.to.field}}`. */
|
|
58
|
+
prompt: z.ZodString;
|
|
59
|
+
/** Tools the agent may use in this step (informational until engine-level scoping). */
|
|
60
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
61
|
+
/** Step ids this step waits for. Steps with no `after` run in parallel. */
|
|
62
|
+
after: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
63
|
+
gate: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
/** Verifiable completion criteria, evaluated one by one (ComplianceGate). */
|
|
65
|
+
criteria: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
66
|
+
/** Agent that evaluates the criteria. MUST differ from the executing agent. */
|
|
67
|
+
evaluator: z.ZodOptional<z.ZodString>;
|
|
68
|
+
/** Whether each criterion requires attached evidence to pass. */
|
|
69
|
+
evidence: z.ZodDefault<z.ZodEnum<["required", "optional"]>>;
|
|
70
|
+
/** `human` pauses the step until a human approves (core ApprovalGate). */
|
|
71
|
+
approval: z.ZodDefault<z.ZodEnum<["human", "none"]>>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
criteria: string[];
|
|
74
|
+
evidence: "required" | "optional";
|
|
75
|
+
approval: "human" | "none";
|
|
76
|
+
evaluator?: string | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
criteria?: string[] | undefined;
|
|
79
|
+
evaluator?: string | undefined;
|
|
80
|
+
evidence?: "required" | "optional" | undefined;
|
|
81
|
+
approval?: "human" | "none" | undefined;
|
|
82
|
+
}>>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
id: string;
|
|
85
|
+
agent: string;
|
|
86
|
+
prompt: string;
|
|
87
|
+
after: string[];
|
|
88
|
+
tools?: string[] | undefined;
|
|
89
|
+
gate?: {
|
|
90
|
+
criteria: string[];
|
|
91
|
+
evidence: "required" | "optional";
|
|
92
|
+
approval: "human" | "none";
|
|
93
|
+
evaluator?: string | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
id: string;
|
|
97
|
+
agent: string;
|
|
98
|
+
prompt: string;
|
|
99
|
+
tools?: string[] | undefined;
|
|
100
|
+
after?: string[] | undefined;
|
|
101
|
+
gate?: {
|
|
102
|
+
criteria?: string[] | undefined;
|
|
103
|
+
evaluator?: string | undefined;
|
|
104
|
+
evidence?: "required" | "optional" | undefined;
|
|
105
|
+
approval?: "human" | "none" | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
export declare const FlowCompensationSchema: z.ZodObject<{
|
|
109
|
+
/** Failure selector: `<stepId>.failed`. */
|
|
110
|
+
on: z.ZodString;
|
|
111
|
+
agent: z.ZodString;
|
|
112
|
+
/** Prompt for the compensating agent. Supports payload interpolation. */
|
|
113
|
+
prompt: z.ZodString;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
agent: string;
|
|
116
|
+
prompt: string;
|
|
117
|
+
on: string;
|
|
118
|
+
}, {
|
|
119
|
+
agent: string;
|
|
120
|
+
prompt: string;
|
|
121
|
+
on: string;
|
|
122
|
+
}>;
|
|
123
|
+
export declare const FlowDefinitionSchema: z.ZodObject<{
|
|
124
|
+
flow: z.ZodString;
|
|
125
|
+
version: z.ZodDefault<z.ZodNumber>;
|
|
126
|
+
trigger: z.ZodObject<{
|
|
127
|
+
/** How the flow is started. `manual` = invoked programmatically. */
|
|
128
|
+
type: z.ZodEnum<["queue", "webhook", "cron", "manual"]>;
|
|
129
|
+
/** Queue name — required when type is `queue`. */
|
|
130
|
+
queue: z.ZodOptional<z.ZodString>;
|
|
131
|
+
/** Route path — required when type is `webhook`. */
|
|
132
|
+
path: z.ZodOptional<z.ZodString>;
|
|
133
|
+
/** Cron expression — required when type is `cron`. */
|
|
134
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
type: "queue" | "webhook" | "cron" | "manual";
|
|
137
|
+
path?: string | undefined;
|
|
138
|
+
queue?: string | undefined;
|
|
139
|
+
schedule?: string | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
type: "queue" | "webhook" | "cron" | "manual";
|
|
142
|
+
path?: string | undefined;
|
|
143
|
+
queue?: string | undefined;
|
|
144
|
+
schedule?: string | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
147
|
+
id: z.ZodString;
|
|
148
|
+
/** Agent id that executes this step. */
|
|
149
|
+
agent: z.ZodString;
|
|
150
|
+
/** Prompt for the agent. Supports `{{payload}}` and `{{payload.path.to.field}}`. */
|
|
151
|
+
prompt: z.ZodString;
|
|
152
|
+
/** Tools the agent may use in this step (informational until engine-level scoping). */
|
|
153
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
154
|
+
/** Step ids this step waits for. Steps with no `after` run in parallel. */
|
|
155
|
+
after: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
156
|
+
gate: z.ZodOptional<z.ZodObject<{
|
|
157
|
+
/** Verifiable completion criteria, evaluated one by one (ComplianceGate). */
|
|
158
|
+
criteria: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
159
|
+
/** Agent that evaluates the criteria. MUST differ from the executing agent. */
|
|
160
|
+
evaluator: z.ZodOptional<z.ZodString>;
|
|
161
|
+
/** Whether each criterion requires attached evidence to pass. */
|
|
162
|
+
evidence: z.ZodDefault<z.ZodEnum<["required", "optional"]>>;
|
|
163
|
+
/** `human` pauses the step until a human approves (core ApprovalGate). */
|
|
164
|
+
approval: z.ZodDefault<z.ZodEnum<["human", "none"]>>;
|
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
|
166
|
+
criteria: string[];
|
|
167
|
+
evidence: "required" | "optional";
|
|
168
|
+
approval: "human" | "none";
|
|
169
|
+
evaluator?: string | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
criteria?: string[] | undefined;
|
|
172
|
+
evaluator?: string | undefined;
|
|
173
|
+
evidence?: "required" | "optional" | undefined;
|
|
174
|
+
approval?: "human" | "none" | undefined;
|
|
175
|
+
}>>;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
id: string;
|
|
178
|
+
agent: string;
|
|
179
|
+
prompt: string;
|
|
180
|
+
after: string[];
|
|
181
|
+
tools?: string[] | undefined;
|
|
182
|
+
gate?: {
|
|
183
|
+
criteria: string[];
|
|
184
|
+
evidence: "required" | "optional";
|
|
185
|
+
approval: "human" | "none";
|
|
186
|
+
evaluator?: string | undefined;
|
|
187
|
+
} | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
id: string;
|
|
190
|
+
agent: string;
|
|
191
|
+
prompt: string;
|
|
192
|
+
tools?: string[] | undefined;
|
|
193
|
+
after?: string[] | undefined;
|
|
194
|
+
gate?: {
|
|
195
|
+
criteria?: string[] | undefined;
|
|
196
|
+
evaluator?: string | undefined;
|
|
197
|
+
evidence?: "required" | "optional" | undefined;
|
|
198
|
+
approval?: "human" | "none" | undefined;
|
|
199
|
+
} | undefined;
|
|
200
|
+
}>, "many">;
|
|
201
|
+
compensation: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
202
|
+
/** Failure selector: `<stepId>.failed`. */
|
|
203
|
+
on: z.ZodString;
|
|
204
|
+
agent: z.ZodString;
|
|
205
|
+
/** Prompt for the compensating agent. Supports payload interpolation. */
|
|
206
|
+
prompt: z.ZodString;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
agent: string;
|
|
209
|
+
prompt: string;
|
|
210
|
+
on: string;
|
|
211
|
+
}, {
|
|
212
|
+
agent: string;
|
|
213
|
+
prompt: string;
|
|
214
|
+
on: string;
|
|
215
|
+
}>, "many">>;
|
|
216
|
+
}, "strip", z.ZodTypeAny, {
|
|
217
|
+
flow: string;
|
|
218
|
+
version: number;
|
|
219
|
+
trigger: {
|
|
220
|
+
type: "queue" | "webhook" | "cron" | "manual";
|
|
221
|
+
path?: string | undefined;
|
|
222
|
+
queue?: string | undefined;
|
|
223
|
+
schedule?: string | undefined;
|
|
224
|
+
};
|
|
225
|
+
steps: {
|
|
226
|
+
id: string;
|
|
227
|
+
agent: string;
|
|
228
|
+
prompt: string;
|
|
229
|
+
after: string[];
|
|
230
|
+
tools?: string[] | undefined;
|
|
231
|
+
gate?: {
|
|
232
|
+
criteria: string[];
|
|
233
|
+
evidence: "required" | "optional";
|
|
234
|
+
approval: "human" | "none";
|
|
235
|
+
evaluator?: string | undefined;
|
|
236
|
+
} | undefined;
|
|
237
|
+
}[];
|
|
238
|
+
compensation: {
|
|
239
|
+
agent: string;
|
|
240
|
+
prompt: string;
|
|
241
|
+
on: string;
|
|
242
|
+
}[];
|
|
243
|
+
}, {
|
|
244
|
+
flow: string;
|
|
245
|
+
trigger: {
|
|
246
|
+
type: "queue" | "webhook" | "cron" | "manual";
|
|
247
|
+
path?: string | undefined;
|
|
248
|
+
queue?: string | undefined;
|
|
249
|
+
schedule?: string | undefined;
|
|
250
|
+
};
|
|
251
|
+
steps: {
|
|
252
|
+
id: string;
|
|
253
|
+
agent: string;
|
|
254
|
+
prompt: string;
|
|
255
|
+
tools?: string[] | undefined;
|
|
256
|
+
after?: string[] | undefined;
|
|
257
|
+
gate?: {
|
|
258
|
+
criteria?: string[] | undefined;
|
|
259
|
+
evaluator?: string | undefined;
|
|
260
|
+
evidence?: "required" | "optional" | undefined;
|
|
261
|
+
approval?: "human" | "none" | undefined;
|
|
262
|
+
} | undefined;
|
|
263
|
+
}[];
|
|
264
|
+
version?: number | undefined;
|
|
265
|
+
compensation?: {
|
|
266
|
+
agent: string;
|
|
267
|
+
prompt: string;
|
|
268
|
+
on: string;
|
|
269
|
+
}[] | undefined;
|
|
270
|
+
}>;
|
|
271
|
+
export type FlowTrigger = z.infer<typeof FlowTriggerSchema>;
|
|
272
|
+
export type FlowGate = z.infer<typeof FlowGateSchema>;
|
|
273
|
+
export type FlowStep = z.infer<typeof FlowStepSchema>;
|
|
274
|
+
export type FlowCompensation = z.infer<typeof FlowCompensationSchema>;
|
|
275
|
+
export type FlowDefinition = z.infer<typeof FlowDefinitionSchema>;
|
|
276
|
+
export type FlowTransitionEvent = 'started' | 'completed' | 'failed' | 'skipped' | 'rejected' | 'approval_requested' | 'gate_evaluation_started' | 'gate_passed' | 'gate_failed' | 'compensation_started' | 'compensation_completed' | 'compensation_failed';
|
|
277
|
+
/** Append-only execution record — every state mutation produces one. */
|
|
278
|
+
export interface FlowTransition {
|
|
279
|
+
at: string;
|
|
280
|
+
stepId: string;
|
|
281
|
+
event: FlowTransitionEvent;
|
|
282
|
+
detail?: string;
|
|
283
|
+
}
|
|
284
|
+
export interface FlowCompensationResult {
|
|
285
|
+
on: string;
|
|
286
|
+
agent: string;
|
|
287
|
+
status: 'completed' | 'failed';
|
|
288
|
+
content?: string;
|
|
289
|
+
error?: string;
|
|
290
|
+
}
|
|
291
|
+
export interface FlowStepResult {
|
|
292
|
+
stepId: string;
|
|
293
|
+
agentId: string;
|
|
294
|
+
content: string;
|
|
295
|
+
status: 'completed' | 'failed' | 'skipped' | 'rejected';
|
|
296
|
+
error?: string;
|
|
297
|
+
}
|
|
298
|
+
export interface FlowResult {
|
|
299
|
+
flow: string;
|
|
300
|
+
version: number;
|
|
301
|
+
status: 'completed' | 'failed' | 'rejected';
|
|
302
|
+
steps: Record<string, FlowStepResult>;
|
|
303
|
+
transitions: FlowTransition[];
|
|
304
|
+
compensations: FlowCompensationResult[];
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/flow/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,6BAA6B,CAAC;AAIhD,eAAO,MAAM,iBAAiB;IAC1B,oEAAoE;;IAEpE,kDAAkD;;IAElD,oDAAoD;;IAEpD,sDAAsD;;;;;;;;;;;;EAExD,CAAC;AAEH,eAAO,MAAM,cAAc;IACvB,6EAA6E;;IAE7E,+EAA+E;;IAE/E,iEAAiE;;IAEjE,0EAA0E;;;;;;;;;;;;EAE5E,CAAC;AAEH,eAAO,MAAM,cAAc;;IAEvB,wCAAwC;;IAExC,oFAAoF;;IAEpF,uFAAuF;;IAEvF,2EAA2E;;;QAlB3E,6EAA6E;;QAE7E,+EAA+E;;QAE/E,iEAAiE;;QAEjE,0EAA0E;;;;;;;;;;;;;;;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;IACf,KAAK,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,aAAa,EAAE,sBAAsB,EAAE,CAAC;CAC3C"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Declarative flow definitions — business flows as data, not code.
|
|
4
|
+
*
|
|
5
|
+
* A FlowDefinition is loaded from YAML, validated, and executed on top of
|
|
6
|
+
* the core WorkflowRunner. Adding a new business flow for a company means
|
|
7
|
+
* writing a YAML file — zero platform code.
|
|
8
|
+
*
|
|
9
|
+
* Gate semantics (criteria/evaluator/evidence) are parsed and carried here
|
|
10
|
+
* so the YAML format is stable; their enforcement lands with ComplianceGate
|
|
11
|
+
* (design doc: diseno-multiagente-enterprise.md, fase 2).
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FlowDefinitionSchema = exports.FlowCompensationSchema = exports.FlowStepSchema = exports.FlowGateSchema = exports.FlowTriggerSchema = void 0;
|
|
15
|
+
const agent_core_1 = require("@backendkit-labs/agent-core");
|
|
16
|
+
// ── Schemas ───────────────────────────────────────────────────────────────────
|
|
17
|
+
exports.FlowTriggerSchema = agent_core_1.z.object({
|
|
18
|
+
/** How the flow is started. `manual` = invoked programmatically. */
|
|
19
|
+
type: agent_core_1.z.enum(['queue', 'webhook', 'cron', 'manual']),
|
|
20
|
+
/** Queue name — required when type is `queue`. */
|
|
21
|
+
queue: agent_core_1.z.string().optional(),
|
|
22
|
+
/** Route path — required when type is `webhook`. */
|
|
23
|
+
path: agent_core_1.z.string().optional(),
|
|
24
|
+
/** Cron expression — required when type is `cron`. */
|
|
25
|
+
schedule: agent_core_1.z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
exports.FlowGateSchema = agent_core_1.z.object({
|
|
28
|
+
/** Verifiable completion criteria, evaluated one by one (ComplianceGate). */
|
|
29
|
+
criteria: agent_core_1.z.array(agent_core_1.z.string()).default([]),
|
|
30
|
+
/** Agent that evaluates the criteria. MUST differ from the executing agent. */
|
|
31
|
+
evaluator: agent_core_1.z.string().optional(),
|
|
32
|
+
/** Whether each criterion requires attached evidence to pass. */
|
|
33
|
+
evidence: agent_core_1.z.enum(['required', 'optional']).default('optional'),
|
|
34
|
+
/** `human` pauses the step until a human approves (core ApprovalGate). */
|
|
35
|
+
approval: agent_core_1.z.enum(['human', 'none']).default('none'),
|
|
36
|
+
});
|
|
37
|
+
exports.FlowStepSchema = agent_core_1.z.object({
|
|
38
|
+
id: agent_core_1.z.string().min(1),
|
|
39
|
+
/** Agent id that executes this step. */
|
|
40
|
+
agent: agent_core_1.z.string().min(1),
|
|
41
|
+
/** Prompt for the agent. Supports `{{payload}}` and `{{payload.path.to.field}}`. */
|
|
42
|
+
prompt: agent_core_1.z.string().min(1),
|
|
43
|
+
/** Tools the agent may use in this step (informational until engine-level scoping). */
|
|
44
|
+
tools: agent_core_1.z.array(agent_core_1.z.string()).optional(),
|
|
45
|
+
/** Step ids this step waits for. Steps with no `after` run in parallel. */
|
|
46
|
+
after: agent_core_1.z.array(agent_core_1.z.string()).default([]),
|
|
47
|
+
gate: exports.FlowGateSchema.optional(),
|
|
48
|
+
});
|
|
49
|
+
exports.FlowCompensationSchema = agent_core_1.z.object({
|
|
50
|
+
/** Failure selector: `<stepId>.failed`. */
|
|
51
|
+
on: agent_core_1.z.string().regex(/^[\w-]+\.failed$/, 'must be "<stepId>.failed"'),
|
|
52
|
+
agent: agent_core_1.z.string().min(1),
|
|
53
|
+
/** Prompt for the compensating agent. Supports payload interpolation. */
|
|
54
|
+
prompt: agent_core_1.z.string().min(1),
|
|
55
|
+
});
|
|
56
|
+
exports.FlowDefinitionSchema = agent_core_1.z.object({
|
|
57
|
+
flow: agent_core_1.z.string().min(1),
|
|
58
|
+
version: agent_core_1.z.number().int().positive().default(1),
|
|
59
|
+
trigger: exports.FlowTriggerSchema,
|
|
60
|
+
steps: agent_core_1.z.array(exports.FlowStepSchema).min(1),
|
|
61
|
+
compensation: agent_core_1.z.array(exports.FlowCompensationSchema).default([]),
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/flow/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,4DAAgD;AAEhD,iFAAiF;AAEpE,QAAA,iBAAiB,GAAG,cAAC,CAAC,MAAM,CAAC;IACtC,oEAAoE;IACpE,IAAI,EAAE,cAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpD,kDAAkD;IAClD,KAAK,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,oDAAoD;IACpD,IAAI,EAAE,cAAC,CAAC,M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BAAsB,GAAG,cAAC,CAAC,MAAM,CAAC;IAC3C,2CAA2C;IAC3C,EAAE,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,2BAA2B,CAAC;IACrE,KAAK,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,yEAAyE;IACzE,MAAM,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,cAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,OAAO,EAAE,yBAAiB;IAC1B,KAAK,EAAE,cAAC,CAAC,KAAK,CAAC,sBAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,YAAY,EAAE,cAAC,CAAC,KAAK,CAAC,8BAAsB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC5D,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ export { VaultWriter } from './rag/VaultWriter';
|
|
|
10
10
|
export type { VaultWriterOptions, WriteNoteParams } from './rag/VaultWriter';
|
|
11
11
|
export { SimpleEmbedder } from './rag/SimpleEmbedder';
|
|
12
12
|
export { GENERAL_PROFILE, SUPPORT_PROFILE, HR_PROFILE, SALES_PROFILE, FINANCE_PROFILE, OPS_PROFILE, ALL_ENTERPRISE_PROFILES, ENTERPRISE_TOOLS, VAULT_FOLDERS, } from './profiles';
|
|
13
|
+
export { FlowTriggerSchema, FlowGateSchema, FlowStepSchema, FlowCompensationSchema, FlowDefinitionSchema, parseFlow, loadFlow, loadFlowsFromDir, FlowLoadError, FlowRunner, interpolate, ComplianceGate, ComplianceGateError, } from './flow';
|
|
14
|
+
export type { FlowTrigger, FlowGate, FlowStep, FlowCompensation, FlowDefinition, FlowTransition, FlowTransitionEvent, FlowStepResult, FlowCompensationResult, FlowResult, FlowRunOptions, FlowAgentRunner, GateCriterion, GateLogEvent, GateLogEntry, GateRecord, ComplianceGateOptions, } from './flow';
|
|
15
|
+
export { PolicySeeder } from './policies';
|
|
16
|
+
export type { PolicySeederOptions } from './policies';
|
|
17
|
+
export { EventPublisher, ReconciliationSweeper } from './events';
|
|
18
|
+
export type { QueueLike, EventPublisherOptions, ReconciliationSweeperOptions, EventEnvelope, EventSchema, PublishOptions, OrphanedEvent, ReconciliationReport, } from './events';
|
|
19
|
+
export { createN8nTriggerTool } from './integrations';
|
|
20
|
+
export type { N8nTriggerOptions } from './integrations';
|
|
13
21
|
export { createEnterpriseSetup } from './factory';
|
|
14
22
|
export type { EnterpriseSetupOptions, EnterpriseSetup } from './factory';
|
|
15
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAC7G,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC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uBAAuB,EACvB,gBAAgB,EAChB,aAAa,GAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,WAAW,EACX,cAAc,EACd,mBAAmB,GACtB,MAAM,QAAQ,CAAC;AAChB,YAAY,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,GACxB,MAAM,QAAQ,CAAC;AAIhB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAItD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjE,YAAY,EACR,SAAS,EACT,qBAAqB,EACrB,4BAA4B,EAC5B,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,EACb,oBAAoB,GACvB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createEnterpriseSetup = exports.VAULT_FOLDERS = exports.ENTERPRISE_TOOLS = exports.ALL_ENTERPRISE_PROFILES = exports.OPS_PROFILE = exports.FINANCE_PROFILE = exports.SALES_PROFILE = exports.HR_PROFILE = exports.SUPPORT_PROFILE = exports.GENERAL_PROFILE = exports.SimpleEmbedder = exports.VaultWriter = exports.VaultIndexer = exports.VectorStore = exports.OLLAMA_EMBED_DEFAULT_MODEL = exports.OLLAMA_EMBED_DEFAULT_HOST = exports.OllamaEmbedder = exports.ObsidianRAGProvider = void 0;
|
|
3
|
+
exports.createEnterpriseSetup = exports.createN8nTriggerTool = exports.ReconciliationSweeper = exports.EventPublisher = exports.PolicySeeder = 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 = exports.VAULT_FOLDERS = exports.ENTERPRISE_TOOLS = exports.ALL_ENTERPRISE_PROFILES = exports.OPS_PROFILE = exports.FINANCE_PROFILE = exports.SALES_PROFILE = exports.HR_PROFILE = exports.SUPPORT_PROFILE = exports.GENERAL_PROFILE = exports.SimpleEmbedder = exports.VaultWriter = exports.VaultIndexer = exports.VectorStore = exports.OLLAMA_EMBED_DEFAULT_MODEL = exports.OLLAMA_EMBED_DEFAULT_HOST = exports.OllamaEmbedder = exports.ObsidianRAGProvider = void 0;
|
|
4
4
|
var ObsidianRAGProvider_1 = require("./rag/ObsidianRAGProvider");
|
|
5
5
|
Object.defineProperty(exports, "ObsidianRAGProvider", { enumerable: true, get: function () { return ObsidianRAGProvider_1.ObsidianRAGProvider; } });
|
|
6
6
|
var OllamaEmbedder_1 = require("./rag/OllamaEmbedder");
|
|
@@ -26,6 +26,31 @@ Object.defineProperty(exports, "OPS_PROFILE", { enumerable: true, get: function
|
|
|
26
26
|
Object.defineProperty(exports, "ALL_ENTERPRISE_PROFILES", { enumerable: true, get: function () { return profiles_1.ALL_ENTERPRISE_PROFILES; } });
|
|
27
27
|
Object.defineProperty(exports, "ENTERPRISE_TOOLS", { enumerable: true, get: function () { return profiles_1.ENTERPRISE_TOOLS; } });
|
|
28
28
|
Object.defineProperty(exports, "VAULT_FOLDERS", { enumerable: true, get: function () { return profiles_1.VAULT_FOLDERS; } });
|
|
29
|
+
// ── Declarative flows ─────────────────────────────────────────────────────────
|
|
30
|
+
var flow_1 = require("./flow");
|
|
31
|
+
Object.defineProperty(exports, "FlowTriggerSchema", { enumerable: true, get: function () { return flow_1.FlowTriggerSchema; } });
|
|
32
|
+
Object.defineProperty(exports, "FlowGateSchema", { enumerable: true, get: function () { return flow_1.FlowGateSchema; } });
|
|
33
|
+
Object.defineProperty(exports, "FlowStepSchema", { enumerable: true, get: function () { return flow_1.FlowStepSchema; } });
|
|
34
|
+
Object.defineProperty(exports, "FlowCompensationSchema", { enumerable: true, get: function () { return flow_1.FlowCompensationSchema; } });
|
|
35
|
+
Object.defineProperty(exports, "FlowDefinitionSchema", { enumerable: true, get: function () { return flow_1.FlowDefinitionSchema; } });
|
|
36
|
+
Object.defineProperty(exports, "parseFlow", { enumerable: true, get: function () { return flow_1.parseFlow; } });
|
|
37
|
+
Object.defineProperty(exports, "loadFlow", { enumerable: true, get: function () { return flow_1.loadFlow; } });
|
|
38
|
+
Object.defineProperty(exports, "loadFlowsFromDir", { enumerable: true, get: function () { return flow_1.loadFlowsFromDir; } });
|
|
39
|
+
Object.defineProperty(exports, "FlowLoadError", { enumerable: true, get: function () { return flow_1.FlowLoadError; } });
|
|
40
|
+
Object.defineProperty(exports, "FlowRunner", { enumerable: true, get: function () { return flow_1.FlowRunner; } });
|
|
41
|
+
Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return flow_1.interpolate; } });
|
|
42
|
+
Object.defineProperty(exports, "ComplianceGate", { enumerable: true, get: function () { return flow_1.ComplianceGate; } });
|
|
43
|
+
Object.defineProperty(exports, "ComplianceGateError", { enumerable: true, get: function () { return flow_1.ComplianceGateError; } });
|
|
44
|
+
// ── Policies-in-vault ─────────────────────────────────────────────────────────
|
|
45
|
+
var policies_1 = require("./policies");
|
|
46
|
+
Object.defineProperty(exports, "PolicySeeder", { enumerable: true, get: function () { return policies_1.PolicySeeder; } });
|
|
47
|
+
// ── Events (broker + reconciliation) ─────────────────────────────────────────
|
|
48
|
+
var events_1 = require("./events");
|
|
49
|
+
Object.defineProperty(exports, "EventPublisher", { enumerable: true, get: function () { return events_1.EventPublisher; } });
|
|
50
|
+
Object.defineProperty(exports, "ReconciliationSweeper", { enumerable: true, get: function () { return events_1.ReconciliationSweeper; } });
|
|
51
|
+
// ── Integrations ──────────────────────────────────────────────────────────────
|
|
52
|
+
var integrations_1 = require("./integrations");
|
|
53
|
+
Object.defineProperty(exports, "createN8nTriggerTool", { enumerable: true, get: function () { return integrations_1.createN8nTriggerTool; } });
|
|
29
54
|
// ── Factory ───────────────────────────────────────────────────────────────────
|
|
30
55
|
var factory_1 = require("./factory");
|
|
31
56
|
Object.defineProperty(exports, "createEnterpriseSetup", { enumerable: true, get: function () { return factory_1.createEnterpriseSetup; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAAvD,0HAAA,mBAAmB,OAAA;AAG5B,uDAA6G;AAApG,gHAAA,cAAc,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAAE,4HAAA,0BAA0B,OAAA;AAG9E,iDAAgD;AAAvC,0GAAA,WAAW,OAAA;AAGpB,mDAAkD;AAAzC,4GAAA,YAAY,OAAA;AAGrB,iDAAgD;AAAvC,0GAAA,WAAW,OAAA;AAGpB,uDAAsD;AAA7C,gHAAA,cAAc,OAAA;AAEvB,iFAAiF;AAEjF,uCAUoB;AAThB,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,sGAAA,UAAU,OAAA;AACV,yGAAA,aAAa,OAAA;AACb,2GAAA,eAAe,OAAA;AACf,uGAAA,WAAW,OAAA;A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AAxD,wGAAA,cAAc,OAAA;AAAE,+GAAA,qBAAqB,OAAA;AAY9C,iFAAiF;AAEjF,+CAAsD;AAA7C,oHAAA,oBAAoB,OAAA;AAG7B,iFAAiF;AAEjF,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createN8nTriggerTool = void 0;
|
|
4
|
+
var n8nTriggerTool_1 = require("./n8nTriggerTool");
|
|
5
|
+
Object.defineProperty(exports, "createN8nTriggerTool", { enumerable: true, get: function () { return n8nTriggerTool_1.createN8nTriggerTool; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwD;AAA/C,sHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@backendkit-labs/agent-core';
|
|
2
|
+
export interface N8nTriggerOptions {
|
|
3
|
+
/** n8n webhook URL. Falls back to the N8N_WEBHOOK_URL environment variable. */
|
|
4
|
+
webhookUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates the `n8n_trigger` tool.
|
|
8
|
+
* POST to the configured n8n webhook with `{ event, correlationId, ...payload }`.
|
|
9
|
+
* Throws if no URL is configured at construction time.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createN8nTriggerTool(opts?: N8nTriggerOptions): ToolDefinition;
|
|
12
|
+
//# sourceMappingURL=n8nTriggerTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n8nTriggerTool.d.ts","sourceRoot":"","sources":["../../src/integrations/n8nTriggerTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAC9B,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,iBAAsB,GAAG,cAAc,CAyCjF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createN8nTriggerTool = createN8nTriggerTool;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const agent_core_1 = require("@backendkit-labs/agent-core");
|
|
6
|
+
/**
|
|
7
|
+
* Creates the `n8n_trigger` tool.
|
|
8
|
+
* POST to the configured n8n webhook with `{ event, correlationId, ...payload }`.
|
|
9
|
+
* Throws if no URL is configured at construction time.
|
|
10
|
+
*/
|
|
11
|
+
function createN8nTriggerTool(opts = {}) {
|
|
12
|
+
const url = opts.webhookUrl ?? process.env.N8N_WEBHOOK_URL;
|
|
13
|
+
if (!url) {
|
|
14
|
+
throw new Error('n8n_trigger requires opts.webhookUrl or the N8N_WEBHOOK_URL env var');
|
|
15
|
+
}
|
|
16
|
+
return (0, agent_core_1.defineTool)({
|
|
17
|
+
name: 'n8n_trigger',
|
|
18
|
+
description: 'Trigger an n8n workflow by POSTing an event payload to a webhook. ' +
|
|
19
|
+
'Returns the correlation ID so the workflow execution can be traced.',
|
|
20
|
+
input: agent_core_1.z.object({
|
|
21
|
+
event: agent_core_1.z.string().describe('Event type / workflow trigger name (e.g. "employee.onboarded", "invoice.approved")'),
|
|
22
|
+
payload: agent_core_1.z.record(agent_core_1.z.unknown()).describe('Arbitrary data forwarded to n8n as the request body alongside the event and correlationId'),
|
|
23
|
+
correlation_id: agent_core_1.z.string().optional().describe('Correlation ID for distributed tracing — auto-generated (UUID v4) when omitted'),
|
|
24
|
+
}),
|
|
25
|
+
execute: async ({ event, payload, correlation_id }) => {
|
|
26
|
+
const corrId = correlation_id ?? (0, node_crypto_1.randomUUID)();
|
|
27
|
+
const body = JSON.stringify({ event, correlationId: corrId, ...payload });
|
|
28
|
+
const res = await fetch(url, {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
|
+
body,
|
|
32
|
+
});
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
throw new Error(`n8n webhook failed (${res.status}): ${await res.text()}`);
|
|
35
|
+
}
|
|
36
|
+
const responseText = (await res.text()).slice(0, 500);
|
|
37
|
+
return [
|
|
38
|
+
`n8n workflow triggered — event: "${event}"`,
|
|
39
|
+
`correlationId: ${corrId}`,
|
|
40
|
+
...(responseText ? [`n8n response: ${responseText}`] : []),
|
|
41
|
+
].join('\n');
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=n8nTriggerTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n8nTriggerTool.js","sourceRoot":"","sources":["../../src/integrations/n8nTriggerTool.ts"],"names":[],"mappings":";;AAcA,oDAyCC;AAvDD,6CAAyC;AACzC,4DAA4D;AAQ5D;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,OAA0B,EAAE;IAC7D,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC3D,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,IAAA,uBAAU,EAAC;QACd,IAAI,EAAE,aAAa;QACnB,WAAW,EACP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AAE,CAAC;aAC7D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface PolicySeederOptions {
|
|
2
|
+
/**
|
|
3
|
+
* When true, overwrites existing policy files.
|
|
4
|
+
* Default: false — existing files are left untouched (preserves company edits).
|
|
5
|
+
*/
|
|
6
|
+
overwrite?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Seeds default business policy notes into the vault under /politicas/.
|
|
10
|
+
*
|
|
11
|
+
* Each policy lives at: {vaultPath}/politicas/{domain}/{slug}.md
|
|
12
|
+
*
|
|
13
|
+
* Policies contain the business rules that were previously hardcoded in agent
|
|
14
|
+
* system prompts (ADR-4). Agents retrieve them at runtime via their search tool,
|
|
15
|
+
* so editing a vault note changes agent behavior without any code deployment.
|
|
16
|
+
*
|
|
17
|
+
* By default, existing policy files are NOT overwritten — the company's edits
|
|
18
|
+
* always take precedence. Pass `overwrite: true` to reset to framework defaults.
|
|
19
|
+
*/
|
|
20
|
+
export declare class PolicySeeder {
|
|
21
|
+
private readonly vaultPath;
|
|
22
|
+
constructor(vaultPath: string);
|
|
23
|
+
/**
|
|
24
|
+
* Seeds all default policies. Returns the paths of files actually written.
|
|
25
|
+
* Skips files that already exist unless `overwrite: true`.
|
|
26
|
+
*/
|
|
27
|
+
seed(opts?: PolicySeederOptions): Promise<string[]>;
|
|
28
|
+
/** Returns the absolute path where a policy note will be written. */
|
|
29
|
+
policyPath(domain: string, slug: string): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=PolicySeeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolicySeeder.d.ts","sourceRoot":"","sources":["../../src/policies/PolicySeeder.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAID;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACT,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IAE9C;;;OAGG;IACG,IAAI,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAe7D,qEAAqE;IACrE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAGnD"}
|