| 1 |
const workflowContext = require.context( |
| 2 |
'.', |
| 3 |
true, |
| 4 |
// Anything not excluded here ships to find-agent as an eligible workflow. |
| 5 |
/^(?!.*\/(tools|components|overrides)\/)(?!\.\/workflows\.js$).*\.js$/, |
| 6 |
); |
| 7 |
export const workflows = workflowContext |
| 8 |
.keys() |
| 9 |
.filter((key) => key !== './workflows.js') |
| 10 |
.map((key) => workflowContext(key).default || workflowContext(key)); |
| 11 |
|
| 12 |
// Merged over the workflow the backend sent, never offered to find-agent. |
| 13 |
const abilityContext = require.context( |
| 14 |
'.', |
| 15 |
true, |
| 16 |
/abilities\/overrides\/.*\.js$/, |
| 17 |
); |
| 18 |
export const abilityWorkflows = Object.fromEntries( |
| 19 |
abilityContext.keys().map((key) => { |
| 20 |
const workflow = abilityContext(key).default || abilityContext(key); |
| 21 |
return [workflow.id, workflow]; |
| 22 |
}), |
| 23 |
); |
| 24 |
|
| 25 |
// Dynamically pull in all tools |
| 26 |
const toolContext = require.context('.', true, /tools\/.*\.js$/); |
| 27 |
export const tools = toolContext.keys().reduce((acc, key) => { |
| 28 |
const id = key.split('/').pop().replace('.js', ''); |
| 29 |
acc[id] = toolContext(key).default || toolContext(key); |
| 30 |
return acc; |
| 31 |
}, {}); |
| 32 |
|