@backendkit-labs/orchestrator-agent 0.1.1

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/AGENT.md ADDED
@@ -0,0 +1,69 @@
1
+ # orchestrator-agent
2
+
3
+ Config-driven orchestration agent. Decomposes natural language tasks into sub-tasks, routes each to the right specialist via `orchestrator.yaml`, and consolidates results. Supports local LLMs (Ollama) and shared knowledge vaults.
4
+
5
+ ## Tools
6
+
7
+ - `orchestrator_run` — decompose and execute a task end-to-end
8
+ - `orchestrator_list_agents` — list configured specialists
9
+ - `orchestrator_status` — get checkpoint status for resume
10
+
11
+ ## orchestrator.yaml
12
+
13
+ ```yaml
14
+ version: 1
15
+
16
+ orchestrator:
17
+ name: "Enterprise Orchestrator"
18
+ provider: deepseek
19
+ vault:
20
+ path: /path/to/shared-vault
21
+ embedder: simple # simple (no deps) | ollama (requires Ollama)
22
+ ollama_host: http://localhost:11434
23
+ ollama_model: nomic-embed-text
24
+
25
+ providers:
26
+ deepseek:
27
+ api_key: ${DEEPSEEK_API_KEY}
28
+ base_url: https://api.deepseek.com
29
+ model: deepseek-chat
30
+ local:
31
+ api_key: ollama
32
+ base_url: http://localhost:11434/v1
33
+ model: llama3.2:3b
34
+
35
+ agents:
36
+ - id: hr
37
+ name: HR Specialist
38
+ description: Recursos humanos, nómina, altas y bajas de empleados
39
+ capabilities: [onboarding, payroll, leave, hr-policies]
40
+ provider: local # dato sensible → Ollama, nunca sale de la empresa
41
+
42
+ - id: finance
43
+ name: Finance Specialist
44
+ description: Presupuestos, facturas y reportes financieros
45
+ capabilities: [budgeting, invoicing, financial-reports, approvals]
46
+ provider: local
47
+
48
+ - id: code
49
+ name: Code Specialist
50
+ description: Desarrollo TypeScript, revisión de código, testing
51
+ capabilities: [typescript, code-review, testing, refactoring]
52
+ provider: deepseek
53
+ transport:
54
+ type: http
55
+ url: http://localhost:3001 # optional: connect to specialist MCP server
56
+ ```
57
+
58
+ ## Provider rules
59
+
60
+ | Data type | Provider | Reason |
61
+ |---|---|---|
62
+ | Personal (HR, payroll, legal) | `local` → Ollama | Never leaves the company |
63
+ | Reasoning, reports, code | `deepseek` or `anthropic` | Better quality |
64
+ | Pilot / no Ollama | `simple` embedder | TF-IDF, no dependencies |
65
+
66
+ ## Adding agents
67
+
68
+ Add an entry to `agents:` in `orchestrator.yaml`. No code changes needed.
69
+ The orchestrator's system prompt is generated from the config at runtime.
@@ -0,0 +1,342 @@
1
+ import { z } from 'zod';
2
+ declare const AgentConfigSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ description: z.ZodString;
6
+ capabilities: z.ZodArray<z.ZodString, "many">;
7
+ provider: z.ZodDefault<z.ZodString>;
8
+ system_prompt: z.ZodOptional<z.ZodString>;
9
+ transport: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
10
+ type: z.ZodLiteral<"stdio">;
11
+ command: z.ZodString;
12
+ args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
13
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ type: "stdio";
16
+ command: string;
17
+ args: string[];
18
+ env?: Record<string, string> | undefined;
19
+ }, {
20
+ type: "stdio";
21
+ command: string;
22
+ args?: string[] | undefined;
23
+ env?: Record<string, string> | undefined;
24
+ }>, z.ZodObject<{
25
+ type: z.ZodLiteral<"http">;
26
+ url: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ type: "http";
29
+ url: string;
30
+ }, {
31
+ type: "http";
32
+ url: string;
33
+ }>]>>;
34
+ gate: z.ZodOptional<z.ZodBoolean>;
35
+ gate_criteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
36
+ domain: z.ZodOptional<z.ZodString>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ name: string;
39
+ provider: string;
40
+ id: string;
41
+ description: string;
42
+ capabilities: string[];
43
+ system_prompt?: string | undefined;
44
+ transport?: {
45
+ type: "stdio";
46
+ command: string;
47
+ args: string[];
48
+ env?: Record<string, string> | undefined;
49
+ } | {
50
+ type: "http";
51
+ url: string;
52
+ } | undefined;
53
+ gate?: boolean | undefined;
54
+ gate_criteria?: string[] | undefined;
55
+ domain?: string | undefined;
56
+ }, {
57
+ name: string;
58
+ id: string;
59
+ description: string;
60
+ capabilities: string[];
61
+ provider?: string | undefined;
62
+ system_prompt?: string | undefined;
63
+ transport?: {
64
+ type: "stdio";
65
+ command: string;
66
+ args?: string[] | undefined;
67
+ env?: Record<string, string> | undefined;
68
+ } | {
69
+ type: "http";
70
+ url: string;
71
+ } | undefined;
72
+ gate?: boolean | undefined;
73
+ gate_criteria?: string[] | undefined;
74
+ domain?: string | undefined;
75
+ }>;
76
+ declare const ProviderConfigSchema: z.ZodObject<{
77
+ api_key: z.ZodOptional<z.ZodString>;
78
+ base_url: z.ZodOptional<z.ZodString>;
79
+ model: z.ZodString;
80
+ }, "strip", z.ZodTypeAny, {
81
+ model: string;
82
+ api_key?: string | undefined;
83
+ base_url?: string | undefined;
84
+ }, {
85
+ model: string;
86
+ api_key?: string | undefined;
87
+ base_url?: string | undefined;
88
+ }>;
89
+ declare const VaultConfigSchema: z.ZodObject<{
90
+ path: z.ZodString;
91
+ embedder: z.ZodDefault<z.ZodEnum<["simple", "ollama"]>>;
92
+ ollama_host: z.ZodDefault<z.ZodString>;
93
+ ollama_model: z.ZodDefault<z.ZodString>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ path: string;
96
+ embedder: "simple" | "ollama";
97
+ ollama_host: string;
98
+ ollama_model: string;
99
+ }, {
100
+ path: string;
101
+ embedder?: "simple" | "ollama" | undefined;
102
+ ollama_host?: string | undefined;
103
+ ollama_model?: string | undefined;
104
+ }>;
105
+ export declare const OrchestratorConfigSchema: z.ZodObject<{
106
+ version: z.ZodDefault<z.ZodNumber>;
107
+ orchestrator: z.ZodObject<{
108
+ name: z.ZodDefault<z.ZodString>;
109
+ provider: z.ZodDefault<z.ZodString>;
110
+ model: z.ZodOptional<z.ZodString>;
111
+ vault: z.ZodOptional<z.ZodObject<{
112
+ path: z.ZodString;
113
+ embedder: z.ZodDefault<z.ZodEnum<["simple", "ollama"]>>;
114
+ ollama_host: z.ZodDefault<z.ZodString>;
115
+ ollama_model: z.ZodDefault<z.ZodString>;
116
+ }, "strip", z.ZodTypeAny, {
117
+ path: string;
118
+ embedder: "simple" | "ollama";
119
+ ollama_host: string;
120
+ ollama_model: string;
121
+ }, {
122
+ path: string;
123
+ embedder?: "simple" | "ollama" | undefined;
124
+ ollama_host?: string | undefined;
125
+ ollama_model?: string | undefined;
126
+ }>>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ name: string;
129
+ provider: string;
130
+ model?: string | undefined;
131
+ vault?: {
132
+ path: string;
133
+ embedder: "simple" | "ollama";
134
+ ollama_host: string;
135
+ ollama_model: string;
136
+ } | undefined;
137
+ }, {
138
+ name?: string | undefined;
139
+ provider?: string | undefined;
140
+ model?: string | undefined;
141
+ vault?: {
142
+ path: string;
143
+ embedder?: "simple" | "ollama" | undefined;
144
+ ollama_host?: string | undefined;
145
+ ollama_model?: string | undefined;
146
+ } | undefined;
147
+ }>;
148
+ providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
149
+ api_key: z.ZodOptional<z.ZodString>;
150
+ base_url: z.ZodOptional<z.ZodString>;
151
+ model: z.ZodString;
152
+ }, "strip", z.ZodTypeAny, {
153
+ model: string;
154
+ api_key?: string | undefined;
155
+ base_url?: string | undefined;
156
+ }, {
157
+ model: string;
158
+ api_key?: string | undefined;
159
+ base_url?: string | undefined;
160
+ }>>>;
161
+ agents: z.ZodArray<z.ZodObject<{
162
+ id: z.ZodString;
163
+ name: z.ZodString;
164
+ description: z.ZodString;
165
+ capabilities: z.ZodArray<z.ZodString, "many">;
166
+ provider: z.ZodDefault<z.ZodString>;
167
+ system_prompt: z.ZodOptional<z.ZodString>;
168
+ transport: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
169
+ type: z.ZodLiteral<"stdio">;
170
+ command: z.ZodString;
171
+ args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
172
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
173
+ }, "strip", z.ZodTypeAny, {
174
+ type: "stdio";
175
+ command: string;
176
+ args: string[];
177
+ env?: Record<string, string> | undefined;
178
+ }, {
179
+ type: "stdio";
180
+ command: string;
181
+ args?: string[] | undefined;
182
+ env?: Record<string, string> | undefined;
183
+ }>, z.ZodObject<{
184
+ type: z.ZodLiteral<"http">;
185
+ url: z.ZodString;
186
+ }, "strip", z.ZodTypeAny, {
187
+ type: "http";
188
+ url: string;
189
+ }, {
190
+ type: "http";
191
+ url: string;
192
+ }>]>>;
193
+ gate: z.ZodOptional<z.ZodBoolean>;
194
+ gate_criteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
195
+ domain: z.ZodOptional<z.ZodString>;
196
+ }, "strip", z.ZodTypeAny, {
197
+ name: string;
198
+ provider: string;
199
+ id: string;
200
+ description: string;
201
+ capabilities: string[];
202
+ system_prompt?: string | undefined;
203
+ transport?: {
204
+ type: "stdio";
205
+ command: string;
206
+ args: string[];
207
+ env?: Record<string, string> | undefined;
208
+ } | {
209
+ type: "http";
210
+ url: string;
211
+ } | undefined;
212
+ gate?: boolean | undefined;
213
+ gate_criteria?: string[] | undefined;
214
+ domain?: string | undefined;
215
+ }, {
216
+ name: string;
217
+ id: string;
218
+ description: string;
219
+ capabilities: string[];
220
+ provider?: string | undefined;
221
+ system_prompt?: string | undefined;
222
+ transport?: {
223
+ type: "stdio";
224
+ command: string;
225
+ args?: string[] | undefined;
226
+ env?: Record<string, string> | undefined;
227
+ } | {
228
+ type: "http";
229
+ url: string;
230
+ } | undefined;
231
+ gate?: boolean | undefined;
232
+ gate_criteria?: string[] | undefined;
233
+ domain?: string | undefined;
234
+ }>, "many">;
235
+ flows: z.ZodOptional<z.ZodArray<z.ZodObject<{
236
+ id: z.ZodString;
237
+ file: z.ZodString;
238
+ trigger: z.ZodOptional<z.ZodString>;
239
+ }, "strip", z.ZodTypeAny, {
240
+ id: string;
241
+ file: string;
242
+ trigger?: string | undefined;
243
+ }, {
244
+ id: string;
245
+ file: string;
246
+ trigger?: string | undefined;
247
+ }>, "many">>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ version: number;
250
+ orchestrator: {
251
+ name: string;
252
+ provider: string;
253
+ model?: string | undefined;
254
+ vault?: {
255
+ path: string;
256
+ embedder: "simple" | "ollama";
257
+ ollama_host: string;
258
+ ollama_model: string;
259
+ } | undefined;
260
+ };
261
+ providers: Record<string, {
262
+ model: string;
263
+ api_key?: string | undefined;
264
+ base_url?: string | undefined;
265
+ }>;
266
+ agents: {
267
+ name: string;
268
+ provider: string;
269
+ id: string;
270
+ description: string;
271
+ capabilities: string[];
272
+ system_prompt?: string | undefined;
273
+ transport?: {
274
+ type: "stdio";
275
+ command: string;
276
+ args: string[];
277
+ env?: Record<string, string> | undefined;
278
+ } | {
279
+ type: "http";
280
+ url: string;
281
+ } | undefined;
282
+ gate?: boolean | undefined;
283
+ gate_criteria?: string[] | undefined;
284
+ domain?: string | undefined;
285
+ }[];
286
+ flows?: {
287
+ id: string;
288
+ file: string;
289
+ trigger?: string | undefined;
290
+ }[] | undefined;
291
+ }, {
292
+ orchestrator: {
293
+ name?: string | undefined;
294
+ provider?: string | undefined;
295
+ model?: string | undefined;
296
+ vault?: {
297
+ path: string;
298
+ embedder?: "simple" | "ollama" | undefined;
299
+ ollama_host?: string | undefined;
300
+ ollama_model?: string | undefined;
301
+ } | undefined;
302
+ };
303
+ agents: {
304
+ name: string;
305
+ id: string;
306
+ description: string;
307
+ capabilities: string[];
308
+ provider?: string | undefined;
309
+ system_prompt?: string | undefined;
310
+ transport?: {
311
+ type: "stdio";
312
+ command: string;
313
+ args?: string[] | undefined;
314
+ env?: Record<string, string> | undefined;
315
+ } | {
316
+ type: "http";
317
+ url: string;
318
+ } | undefined;
319
+ gate?: boolean | undefined;
320
+ gate_criteria?: string[] | undefined;
321
+ domain?: string | undefined;
322
+ }[];
323
+ version?: number | undefined;
324
+ providers?: Record<string, {
325
+ model: string;
326
+ api_key?: string | undefined;
327
+ base_url?: string | undefined;
328
+ }> | undefined;
329
+ flows?: {
330
+ id: string;
331
+ file: string;
332
+ trigger?: string | undefined;
333
+ }[] | undefined;
334
+ }>;
335
+ export type OrchestratorConfig = z.infer<typeof OrchestratorConfigSchema>;
336
+ export type AgentConfig = z.infer<typeof AgentConfigSchema>;
337
+ export type ProviderConfig = z.infer<typeof ProviderConfigSchema>;
338
+ export type VaultConfig = z.infer<typeof VaultConfigSchema>;
339
+ export declare function loadConfig(configPath: string): OrchestratorConfig;
340
+ export declare function resolveProviderConfig(config: OrchestratorConfig, providerId: string): ProviderConfig | null;
341
+ export {};
342
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWrB,CAAC;AAEH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;EAIxB,CAAC;AAEH,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;EAKrB,CAAC;AAQH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC,CAAC;AAIH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,WAAW,GAAU,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACnE,MAAM,MAAM,cAAc,GAAO,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAU,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAInE,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAajE;AAiBD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAE3G"}
package/dist/config.js ADDED
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ import { readFileSync, existsSync } from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import * as yaml from 'yaml';
5
+ // ── Schemas ───────────────────────────────────────────────────────────────────
6
+ const TransportSchema = z.discriminatedUnion('type', [
7
+ z.object({
8
+ type: z.literal('stdio'),
9
+ command: z.string(),
10
+ args: z.array(z.string()).default([]),
11
+ env: z.record(z.string()).optional(),
12
+ }),
13
+ z.object({
14
+ type: z.literal('http'),
15
+ url: z.string(),
16
+ }),
17
+ ]);
18
+ const AgentConfigSchema = z.object({
19
+ id: z.string(),
20
+ name: z.string(),
21
+ description: z.string(),
22
+ capabilities: z.array(z.string()),
23
+ provider: z.string().default('default'),
24
+ system_prompt: z.string().optional(),
25
+ transport: TransportSchema.optional(),
26
+ gate: z.boolean().optional(), // pause for human approval after this agent
27
+ gate_criteria: z.array(z.string()).optional(), // criteria shown to the approver
28
+ domain: z.string().optional(), // enterprise reflection domain (e.g. 'rrhh', 'legal')
29
+ });
30
+ const ProviderConfigSchema = z.object({
31
+ api_key: z.string().optional(),
32
+ base_url: z.string().optional(),
33
+ model: z.string(),
34
+ });
35
+ const VaultConfigSchema = z.object({
36
+ path: z.string(),
37
+ embedder: z.enum(['simple', 'ollama']).default('simple'),
38
+ ollama_host: z.string().default('http://localhost:11434'),
39
+ ollama_model: z.string().default('nomic-embed-text'),
40
+ });
41
+ const FlowEntryConfigSchema = z.object({
42
+ id: z.string(),
43
+ file: z.string(),
44
+ trigger: z.string().optional(),
45
+ });
46
+ export const OrchestratorConfigSchema = z.object({
47
+ version: z.number().default(1),
48
+ orchestrator: z.object({
49
+ name: z.string().default('Orchestrator'),
50
+ provider: z.string().default('default'),
51
+ model: z.string().optional(),
52
+ vault: VaultConfigSchema.optional(),
53
+ }),
54
+ providers: z.record(ProviderConfigSchema).default({}),
55
+ agents: z.array(AgentConfigSchema).min(1, 'At least one agent must be configured'),
56
+ flows: z.array(FlowEntryConfigSchema).optional(),
57
+ });
58
+ // ── Loader ────────────────────────────────────────────────────────────────────
59
+ export function loadConfig(configPath) {
60
+ const resolved = path.resolve(configPath);
61
+ if (!existsSync(resolved)) {
62
+ throw new Error(`Config not found: ${resolved}`);
63
+ }
64
+ const raw = yaml.parse(readFileSync(resolved, 'utf-8'));
65
+ const expanded = expandEnv(raw);
66
+ const result = OrchestratorConfigSchema.safeParse(expanded);
67
+ if (!result.success) {
68
+ const issues = result.error.issues.map(i => ` ${i.path.join('.')}: ${i.message}`).join('\n');
69
+ throw new Error(`Invalid orchestrator config:\n${issues}`);
70
+ }
71
+ return result.data;
72
+ }
73
+ // ── Helpers ───────────────────────────────────────────────────────────────────
74
+ function expandEnv(obj) {
75
+ if (typeof obj === 'string') {
76
+ return obj.replace(/\$\{(\w+)\}/g, (_, key) => process.env[key] ?? '');
77
+ }
78
+ if (Array.isArray(obj))
79
+ return obj.map(expandEnv);
80
+ if (obj !== null && typeof obj === 'object') {
81
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, expandEnv(v)]));
82
+ }
83
+ return obj;
84
+ }
85
+ export function resolveProviderConfig(config, providerId) {
86
+ return config.providers[providerId] ?? null;
87
+ }
88
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,iFAAiF;AAEjF,MAAM,eAAe,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACjD,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QACxB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KACvC,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAc,CAAC,CAAC,MAAM,EAAE;IAC1B,IAAI,EAAY,CAAC,CAAC,MAAM,EAAE;IAC1B,WAAW,EAAK,CAAC,CAAC,MAAM,EAAE;IAC1B,YAAY,EAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,QAAQ,EAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;IAC7C,aAAa,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backendkit-labs/agent-core';
3
+ import type { OrchestratorConfig } from './config.js';
4
+ import type { TaskPlan } from './planner.js';
5
+ export interface ExecutionResult {
6
+ subtask_id: string;
7
+ agent_id: string;
8
+ task: string;
9
+ result: string;
10
+ success: boolean;
11
+ duration_ms: number;
12
+ }
13
+ export interface PlanExecution {
14
+ plan: TaskPlan;
15
+ results: ExecutionResult[];
16
+ summary: string;
17
+ complete: boolean;
18
+ }
19
+ /** Returned instead of PlanExecution when a gate step is reached. */
20
+ export interface GateHit {
21
+ gateRequired: true;
22
+ stepId: string;
23
+ agentId: string;
24
+ output: string;
25
+ criteria: string[];
26
+ completedSoFar: ExecutionResult[];
27
+ /** IDs of policyRules that forced this gate (empty when gate is explicit in YAML/config). */
28
+ appliedRuleIds: string[];
29
+ }
30
+ /**
31
+ * Minimal interface for the enterprise reflection adapter (Cable 2).
32
+ * EnterpriseReflection from @backendkit-labs/agent-enterprise satisfies this
33
+ * structurally — no direct import needed, avoiding circular dep on publish cycle.
34
+ */
35
+ export interface ReflectionAdapter {
36
+ activeRules(filter?: {
37
+ domain?: string;
38
+ }): Promise<Array<{
39
+ id: string;
40
+ name: string;
41
+ trigger: {
42
+ domain: string;
43
+ pattern: string;
44
+ minOccurrences: number;
45
+ };
46
+ if: {
47
+ domain?: string | string[];
48
+ keywords?: string[];
49
+ [k: string]: unknown;
50
+ };
51
+ then: {
52
+ mustInclude?: string[];
53
+ mustPass?: string[];
54
+ mustExecute?: string[];
55
+ requireArchitectureReview?: boolean;
56
+ requireSecurityReview?: boolean;
57
+ requireQaApproval?: boolean;
58
+ [k: string]: unknown;
59
+ };
60
+ }>>;
61
+ recordRuleOutcome(ruleId: string, outcome: 'success' | 'failure'): Promise<void>;
62
+ }
63
+ export interface ExecutorOptions {
64
+ config: OrchestratorConfig;
65
+ ragSearchFn?: (query: string) => Promise<string>;
66
+ onProgress?: (msg: string) => void;
67
+ /** Enterprise reflection adapter for deterministic rule enforcement (Cable 2). */
68
+ reflection?: ReflectionAdapter;
69
+ }
70
+ export declare class PlanExecutor {
71
+ private readonly config;
72
+ private readonly ragSearchFn;
73
+ private readonly onProgress;
74
+ private readonly reflection;
75
+ constructor(opts: ExecutorOptions);
76
+ /**
77
+ * Execute a plan from scratch or resume after a gate approval.
78
+ *
79
+ * @param plan Full task plan.
80
+ * @param priorResults Steps already completed in a previous execution segment
81
+ * (used when resuming after a gate). Those steps are treated
82
+ * as done and skipped.
83
+ */
84
+ execute(plan: TaskPlan, priorResults?: ExecutionResult[]): Promise<PlanExecution | GateHit>;
85
+ private runSubTask;
86
+ private runSpecialist;
87
+ /**
88
+ * Cable 2: query active policyRules and match against this subtask.
89
+ * Returns matched rule IDs and the criteria text to show the human approver.
90
+ * No-op when reflection is not configured.
91
+ */
92
+ private checkActiveRules;
93
+ private consolidate;
94
+ }
95
+ export declare function buildOrchestratorEngine(opts: ExecutorOptions & {
96
+ orchestratorProfile: AgentProfile;
97
+ ragTool?: ReturnType<typeof defineTool>;
98
+ }): AgentEngine;
99
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EAKX,UAAU,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,6BAA6B,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAW,MAAM,cAAc,CAAC;AAKtD,MAAM,WAAW,eAAe;IAC5B,UAAU,EAAG,MAAM,CAAC;IACpB,QAAQ,EAAK,MAAM,CAAC;IACpB,IAAI,EAAS,MAAM,CAAC;IACpB,MAAM,EAAO,MAAM,CAAC;IACpB,OAAO,EAAM,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAM,QAAQ,CAAC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