robal-framework 0.1.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.
@@ -0,0 +1,51 @@
1
+ import type { OrchestratorConfig, TaskOutput, TaskInput } from './types';
2
+ import { Team } from './team';
3
+ /**
4
+ * Orchestrator — coordinates multiple teams with different agents.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const orc = new Orchestrator({
9
+ * teams: {
10
+ * research: { agent: researchAgent },
11
+ * writer: { agent: writerAgent, reviewer: editorAgent },
12
+ * },
13
+ * channels: [
14
+ * { from: 'research', to: 'writer' },
15
+ * ],
16
+ * });
17
+ *
18
+ * // Run a single team
19
+ * const result = await orc.run('research', 'Find market trends for AI agents');
20
+ *
21
+ * // Run a pipeline (research → writer, connected by channel)
22
+ * const final = await orc.pipeline('research', 'Write a report on AI agent market');
23
+ * ```
24
+ */
25
+ export declare class Orchestrator {
26
+ private teams;
27
+ private channels;
28
+ private emit;
29
+ constructor(config: OrchestratorConfig);
30
+ /** Get a team by ID. */
31
+ team(id: string): Team;
32
+ /** Run a task on a specific team. */
33
+ run(teamId: string, prompt: string, context?: TaskInput['context']): Promise<TaskOutput>;
34
+ /**
35
+ * Run a pipeline starting from a team.
36
+ * Output flows through channels to downstream teams.
37
+ * Channels with gates hold output until the gate approves.
38
+ */
39
+ pipeline(startTeamId: string, prompt: string, context?: TaskInput['context']): Promise<TaskOutput>;
40
+ /**
41
+ * Run multiple teams in parallel on different prompts.
42
+ * Useful for fan-out patterns.
43
+ */
44
+ parallel(tasks: {
45
+ teamId: string;
46
+ prompt: string;
47
+ context?: TaskInput['context'];
48
+ }[]): Promise<TaskOutput[]>;
49
+ private routeThrough;
50
+ }
51
+ //# sourceMappingURL=orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAqB,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,IAAI,CAAqC;gBAErC,MAAM,EAAE,kBAAkB;IAStC,wBAAwB;IACxB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMtB,qCAAqC;IAC/B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9F;;;;OAIG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA6CxG;;;OAGG;IACG,QAAQ,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;KAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YASpG,YAAY;CA2B3B"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Orchestrator = void 0;
4
+ const team_1 = require("./team");
5
+ /**
6
+ * Orchestrator — coordinates multiple teams with different agents.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const orc = new Orchestrator({
11
+ * teams: {
12
+ * research: { agent: researchAgent },
13
+ * writer: { agent: writerAgent, reviewer: editorAgent },
14
+ * },
15
+ * channels: [
16
+ * { from: 'research', to: 'writer' },
17
+ * ],
18
+ * });
19
+ *
20
+ * // Run a single team
21
+ * const result = await orc.run('research', 'Find market trends for AI agents');
22
+ *
23
+ * // Run a pipeline (research → writer, connected by channel)
24
+ * const final = await orc.pipeline('research', 'Write a report on AI agent market');
25
+ * ```
26
+ */
27
+ class Orchestrator {
28
+ teams = new Map();
29
+ channels;
30
+ emit;
31
+ constructor(config) {
32
+ this.emit = config.onEvent || (() => { });
33
+ this.channels = config.channels || [];
34
+ for (const [id, teamConfig] of Object.entries(config.teams)) {
35
+ this.teams.set(id, new team_1.Team(id, teamConfig, this.emit));
36
+ }
37
+ }
38
+ /** Get a team by ID. */
39
+ team(id) {
40
+ const t = this.teams.get(id);
41
+ if (!t)
42
+ throw new Error(`Team '${id}' not found. Available: ${[...this.teams.keys()].join(', ')}`);
43
+ return t;
44
+ }
45
+ /** Run a task on a specific team. */
46
+ async run(teamId, prompt, context) {
47
+ return this.team(teamId).run(prompt, context);
48
+ }
49
+ /**
50
+ * Run a pipeline starting from a team.
51
+ * Output flows through channels to downstream teams.
52
+ * Channels with gates hold output until the gate approves.
53
+ */
54
+ async pipeline(startTeamId, prompt, context) {
55
+ let currentOutput = await this.run(startTeamId, prompt, context);
56
+ if (currentOutput.status === 'failed')
57
+ return currentOutput;
58
+ const visited = new Set([startTeamId]);
59
+ let currentTeamId = startTeamId;
60
+ while (true) {
61
+ const outgoing = (this.channels || []).filter(c => c.from === currentTeamId && !visited.has(c.to));
62
+ if (outgoing.length === 0)
63
+ break;
64
+ if (outgoing.length === 1) {
65
+ // Linear chain
66
+ const channel = outgoing[0];
67
+ const routed = await this.routeThrough(channel, currentOutput.output, context);
68
+ if (!routed)
69
+ break;
70
+ currentOutput = routed.output;
71
+ currentTeamId = channel.to;
72
+ visited.add(currentTeamId);
73
+ if (currentOutput.status === 'failed')
74
+ break;
75
+ }
76
+ else {
77
+ // Fan-out: run downstream teams in parallel
78
+ const results = await Promise.allSettled(outgoing.map(channel => this.routeThrough(channel, currentOutput.output, context)));
79
+ const outputs = [];
80
+ for (let i = 0; i < results.length; i++) {
81
+ const r = results[i];
82
+ visited.add(outgoing[i].to);
83
+ if (r.status === 'fulfilled' && r.value) {
84
+ outputs.push(`[${outgoing[i].to}]: ${r.value.output.output}`);
85
+ }
86
+ else {
87
+ outputs.push(`[${outgoing[i].to}]: Error`);
88
+ }
89
+ }
90
+ currentOutput = { status: 'completed', output: outputs.join('\n\n---\n\n') };
91
+ break; // Fan-out is a terminal step
92
+ }
93
+ }
94
+ return currentOutput;
95
+ }
96
+ /**
97
+ * Run multiple teams in parallel on different prompts.
98
+ * Useful for fan-out patterns.
99
+ */
100
+ async parallel(tasks) {
101
+ const results = await Promise.allSettled(tasks.map(t => this.run(t.teamId, t.prompt, t.context)));
102
+ return results.map(r => r.status === 'fulfilled' ? r.value : { status: 'failed', output: '', error: r.reason?.message });
103
+ }
104
+ async routeThrough(channel, output, context) {
105
+ // Gate check
106
+ if (channel.gate) {
107
+ const allowed = await channel.gate(output);
108
+ if (!allowed) {
109
+ this.emit({ type: 'channel:gated', from: channel.from, to: channel.to, taskId: '' });
110
+ return null;
111
+ }
112
+ }
113
+ // Transform
114
+ const transformed = channel.transform ? channel.transform(output) : output;
115
+ this.emit({ type: 'channel:routed', from: channel.from, to: channel.to, taskId: '' });
116
+ const nextContext = {
117
+ ...context,
118
+ previousOutputs: [...(context?.previousOutputs || []), output],
119
+ };
120
+ const result = await this.team(channel.to).run(transformed, nextContext);
121
+ return { output: result };
122
+ }
123
+ }
124
+ exports.Orchestrator = Orchestrator;
125
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":";;;AACA,iCAA8B;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,YAAY;IACf,KAAK,GAAsB,IAAI,GAAG,EAAE,CAAC;IACrC,QAAQ,CAAiC;IACzC,IAAI,CAAqC;IAEjD,YAAY,MAA0B;QACpC,IAAI,CAAC,IAAI,GAAG,MAA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D,MAAc,EACd,OAA8B;QAE9B,aAAa;QACb,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;gBACrF,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,YAAY;QACZ,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAE3E,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QAEtF,MAAM,WAAW,GAAyB;YACxC,GAAG,OAAO;YACV,eAAe,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC;SAC/D,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACzE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AApHD,oCAoHC"}
@@ -0,0 +1,94 @@
1
+ import type { Agent, TaskInput, TaskOutput, ReviewResult } from './types';
2
+ export interface BridgeHandlers {
3
+ delegate: (subtasks: {
4
+ prompt: string;
5
+ name?: string;
6
+ }[]) => Promise<string[]>;
7
+ submitReview: (result: ReviewResult) => void;
8
+ }
9
+ /**
10
+ * Local HTTP server that exposes framework capabilities to any agent process.
11
+ * Agents call these endpoints via curl, fetch, subprocess — any language.
12
+ *
13
+ * Endpoints:
14
+ * POST /delegate — spawn sub-agents, returns results
15
+ * POST /submit-review — submit review verdict
16
+ * POST /submit-result — submit final task output
17
+ * GET /task — get current task info
18
+ * GET /health — health check
19
+ */
20
+ export declare class AgentServer {
21
+ private server;
22
+ private handlers;
23
+ private currentTask;
24
+ private reviewResolve;
25
+ private resultResolve;
26
+ readonly port: number;
27
+ constructor(port?: number);
28
+ start(): Promise<number>;
29
+ stop(): Promise<void>;
30
+ setHandlers(handlers: BridgeHandlers): void;
31
+ setTask(task: TaskInput): void;
32
+ waitForReview(): Promise<ReviewResult>;
33
+ waitForResult(): Promise<TaskOutput>;
34
+ private handle;
35
+ private json;
36
+ private readBody;
37
+ }
38
+ /** Description of an available agent for delegation */
39
+ export interface AvailableAgent {
40
+ name: string;
41
+ description: string;
42
+ }
43
+ /**
44
+ * Builds the capability instructions the framework injects for the agent.
45
+ * The agent receives these so it knows what it can do — delegate, submit results, etc.
46
+ */
47
+ export declare function buildInstructions(baseUrl: string, canDelegate: boolean, task: TaskInput, availableAgents?: AvailableAgent[]): string;
48
+ /**
49
+ * Wraps any external process as an Agent by exposing the bridge server.
50
+ *
51
+ * Two modes:
52
+ * - **Simple mode**: just pass `command` — the framework builds the full prompt
53
+ * with capability instructions and pipes it to your command.
54
+ * - **Custom mode**: pass `run` for full control over how the agent is invoked.
55
+ *
56
+ * The agent process receives env vars including ROBAL_INSTRUCTIONS which contains
57
+ * the full prompt with task, context, and available actions (delegate, submit, etc).
58
+ * The agent just needs to follow the instructions.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * // Simple: framework builds prompt, pipes to your CLI
63
+ * const { agent } = await createAgent({
64
+ * command: 'kiro-cli chat --no-interactive --trust-all-tools',
65
+ * });
66
+ *
67
+ * // Custom: full control
68
+ * const { agent } = await createAgent({
69
+ * run: async (task, env) => {
70
+ * execSync(`my-agent`, { env: { ...process.env, ...env } });
71
+ * },
72
+ * });
73
+ * ```
74
+ */
75
+ export declare function createAgent(opts: {
76
+ /** Shell command to run. Framework pipes ROBAL_INSTRUCTIONS as stdin. */
77
+ command?: string;
78
+ /** Custom run function for full control. */
79
+ run?: (task: TaskInput, env: Record<string, string>) => Promise<string | void>;
80
+ /** Agents available for delegation. Shown to the agent so it knows who to delegate to. */
81
+ availableAgents?: AvailableAgent[];
82
+ port?: number;
83
+ timeoutMs?: number;
84
+ }): Promise<{
85
+ agent: Agent;
86
+ bridge: AgentServer;
87
+ }>;
88
+ /**
89
+ * Creates a Reviewer that waits for an external process to POST to /submit-review.
90
+ */
91
+ export declare function createReviewer(bridge: AgentServer): {
92
+ reviewer: import('./types').Reviewer;
93
+ };
94
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/E,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC9C;AAED;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,aAAa,CAAiD;IACtE,OAAO,CAAC,aAAa,CAA+C;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,SAAI;IAId,KAAK,I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CASA"}
package/dist/server.js ADDED
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AgentServer = void 0;
37
+ exports.buildInstructions = buildInstructions;
38
+ exports.createAgent = createAgent;
39
+ exports.createReviewer = createReviewer;
40
+ const http = __importStar(require("http"));
41
+ /**
42
+ * Local HTTP server that exposes framework capabilities to any agent process.
43
+ * Agents call these endpoints via curl, fetch, subprocess — any language.
44
+ *
45
+ * Endpoints:
46
+ * POST /delegate — spawn sub-agents, returns results
47
+ * POST /submit-review — submit review verdict
48
+ * POST /submit-result — submit final task output
49
+ * GET /task — get current task info
50
+ * GET /health — health check
51
+ */
52
+ class AgentServer {
53
+ server = null;
54
+ handlers = null;
55
+ currentTask = null;
56
+ reviewResolve = null;
57
+ resultResolve = null;
58
+ port;
59
+ constructor(port = 0) {
60
+ this.port = port;
61
+ }
62
+ async start() {
63
+ return new Promise((resolve) => {
64
+ this.server = http.createServer((req, res) => this.handle(req, res));
65
+ this.server.listen(this.port, '127.0.0.1', () => {
66
+ const addr = this.server.address();
67
+ this.port = addr.port;
68
+ resolve(addr.port);
69
+ });
70
+ });
71
+ }
72
+ stop() {
73
+ return new Promise((resolve) => {
74
+ if (this.server)
75
+ this.server.close(() => resolve());
76
+ else
77
+ resolve();
78
+ });
79
+ }
80
+ setHandlers(handlers) { this.handlers = handlers; }
81
+ setTask(task) { this.currentTask = task; }
82
+ waitForReview() {
83
+ return new Promise((resolve) => { this.reviewResolve = resolve; });
84
+ }
85
+ waitForResult() {
86
+ return new Promise((resolve) => { this.resultResolve = resolve; });
87
+ }
88
+ handle(req, res) {
89
+ const url = req.url || '';
90
+ const method = req.method || '';
91
+ res.setHeader('Access-Control-Allow-Origin', '*');
92
+ res.setHeader('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
93
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
94
+ if (method === 'OPTIONS') {
95
+ res.writeHead(200);
96
+ res.end();
97
+ return;
98
+ }
99
+ if (method === 'GET' && url === '/health') {
100
+ this.json(res, 200, { ok: true });
101
+ return;
102
+ }
103
+ if (method === 'GET' && url === '/task') {
104
+ if (!this.currentTask) {
105
+ this.json(res, 404, { error: 'No active task' });
106
+ return;
107
+ }
108
+ const { delegate, ...safe } = this.currentTask;
109
+ this.json(res, 200, { ...safe, canDelegate: !!delegate });
110
+ return;
111
+ }
112
+ if (method === 'POST' && url === '/delegate') {
113
+ this.readBody(req, async (body) => {
114
+ if (!this.handlers?.delegate) {
115
+ this.json(res, 400, { error: 'Delegation not available' });
116
+ return;
117
+ }
118
+ try {
119
+ const { subtasks } = body;
120
+ if (!Array.isArray(subtasks)) {
121
+ this.json(res, 400, { error: 'subtasks must be an array' });
122
+ return;
123
+ }
124
+ const results = await this.handlers.delegate(subtasks);
125
+ this.json(res, 200, { results });
126
+ }
127
+ catch (err) {
128
+ this.json(res, 500, { error: err.message });
129
+ }
130
+ });
131
+ return;
132
+ }
133
+ if (method === 'POST' && url === '/submit-review') {
134
+ this.readBody(req, (body) => {
135
+ if (!this.reviewResolve) {
136
+ this.json(res, 400, { error: 'No review pending' });
137
+ return;
138
+ }
139
+ const result = {
140
+ approved: !!body.approved,
141
+ confidence: typeof body.confidence === 'number' ? body.confidence : 0.5,
142
+ feedback: body.feedback || '',
143
+ };
144
+ this.reviewResolve(result);
145
+ this.reviewResolve = null;
146
+ this.json(res, 200, { ok: true });
147
+ });
148
+ return;
149
+ }
150
+ if (method === 'POST' && url === '/submit-result') {
151
+ this.readBody(req, (body) => {
152
+ if (!this.resultResolve) {
153
+ this.json(res, 400, { error: 'No result pending' });
154
+ return;
155
+ }
156
+ const result = {
157
+ status: body.status || 'completed',
158
+ output: body.output || '',
159
+ artifacts: body.artifacts,
160
+ usage: body.usage,
161
+ error: body.error,
162
+ };
163
+ this.resultResolve(result);
164
+ this.resultResolve = null;
165
+ this.json(res, 200, { ok: true });
166
+ });
167
+ return;
168
+ }
169
+ this.json(res, 404, { error: 'Not found' });
170
+ }
171
+ json(res, status, body) {
172
+ res.writeHead(status, { 'Content-Type': 'application/json' });
173
+ res.end(JSON.stringify(body));
174
+ }
175
+ readBody(req, cb) {
176
+ let data = '';
177
+ req.on('data', (chunk) => data += chunk);
178
+ req.on('end', () => {
179
+ try {
180
+ cb(JSON.parse(data));
181
+ }
182
+ catch {
183
+ cb({});
184
+ }
185
+ });
186
+ }
187
+ }
188
+ exports.AgentServer = AgentServer;
189
+ /**
190
+ * Builds the capability instructions the framework injects for the agent.
191
+ * The agent receives these so it knows what it can do — delegate, submit results, etc.
192
+ */
193
+ function buildInstructions(baseUrl, canDelegate, task, availableAgents) {
194
+ const lines = [
195
+ '=== ROBAL FRAMEWORK ===',
196
+ 'You are an agent managed by the Robal orchestration framework.',
197
+ '',
198
+ `Your task: ${task.prompt}`,
199
+ ];
200
+ if (task.feedback) {
201
+ lines.push('', `Previous attempt was rejected. Feedback: ${task.feedback}`);
202
+ if (task.previousOutput) {
203
+ lines.push('', `Your previous output was:`, task.previousOutput);
204
+ }
205
+ }
206
+ if (task.context?.previousOutputs?.length) {
207
+ lines.push('', 'Context from previous steps:', ...task.context.previousOutputs.map((o, i) => `[Step ${i + 1}]: ${o}`));
208
+ }
209
+ lines.push('', '=== AVAILABLE ACTIONS ===', '', '1. SUBMIT YOUR RESULT (required when done):', ` curl -s -X POST ${baseUrl}/submit-result -H "Content-Type: application/json" -d '{"status":"completed","output":"YOUR_OUTPUT"}'`, ' Replace YOUR_OUTPUT with your final answer/output.');
210
+ if (canDelegate) {
211
+ lines.push('', '2. DELEGATE TO SUB-AGENTS (optional — if the task is complex, break it up):', ` curl -s -X POST ${baseUrl}/delegate -H "Content-Type: application/json" -d '{"subtasks":[{"prompt":"subtask 1","name":"agent-name"},{"prompt":"subtask 2","name":"agent-name"}]}'`, ' This returns {"results":["output1","output2"]} with each sub-agent\'s output.', ' You can then use these results to compose your final answer.', ' Use the "name" field to pick which agent handles each subtask.');
212
+ if (availableAgents?.length) {
213
+ lines.push('', ' Available agents you can delegate to:', ...availableAgents.map(a => ` - "${a.name}": ${a.description}`));
214
+ }
215
+ }
216
+ lines.push('', '3. READ FULL TASK DETAILS (optional):', ` curl -s ${baseUrl}/task`, '', '=== INSTRUCTIONS ===', canDelegate
217
+ ? 'Decide: either do the work yourself, or delegate subtasks to sub-agents. Then submit your result.'
218
+ : 'Do the work and submit your result.', '===================');
219
+ return lines.join('\n');
220
+ }
221
+ /**
222
+ * Wraps any external process as an Agent by exposing the bridge server.
223
+ *
224
+ * Two modes:
225
+ * - **Simple mode**: just pass `command` — the framework builds the full prompt
226
+ * with capability instructions and pipes it to your command.
227
+ * - **Custom mode**: pass `run` for full control over how the agent is invoked.
228
+ *
229
+ * The agent process receives env vars including ROBAL_INSTRUCTIONS which contains
230
+ * the full prompt with task, context, and available actions (delegate, submit, etc).
231
+ * The agent just needs to follow the instructions.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * // Simple: framework builds prompt, pipes to your CLI
236
+ * const { agent } = await createAgent({
237
+ * command: 'kiro-cli chat --no-interactive --trust-all-tools',
238
+ * });
239
+ *
240
+ * // Custom: full control
241
+ * const { agent } = await createAgent({
242
+ * run: async (task, env) => {
243
+ * execSync(`my-agent`, { env: { ...process.env, ...env } });
244
+ * },
245
+ * });
246
+ * ```
247
+ */
248
+ async function createAgent(opts) {
249
+ const bridge = new AgentServer(opts.port || 0);
250
+ const port = await bridge.start();
251
+ const baseUrl = `http://127.0.0.1:${port}`;
252
+ const timeout = opts.timeoutMs ?? 300_000;
253
+ const agent = {
254
+ async execute(task) {
255
+ bridge.setTask(task);
256
+ bridge.setHandlers({
257
+ delegate: task.delegate || (async () => { throw new Error('Delegation not available at this depth'); }),
258
+ submitReview: () => { },
259
+ });
260
+ const canDelegate = !!task.delegate;
261
+ const instructions = buildInstructions(baseUrl, canDelegate, task, opts.availableAgents);
262
+ const env = {
263
+ ROBAL_BRIDGE_URL: baseUrl,
264
+ ROBAL_TASK_URL: `${baseUrl}/task`,
265
+ ROBAL_DELEGATE_URL: `${baseUrl}/delegate`,
266
+ ROBAL_RESULT_URL: `${baseUrl}/submit-result`,
267
+ ROBAL_TASK_ID: task.id,
268
+ ROBAL_TEAM_ID: task.teamId,
269
+ ROBAL_PROMPT: task.prompt,
270
+ ROBAL_CAN_DELEGATE: canDelegate ? 'true' : 'false',
271
+ ROBAL_DEPTH: String(task.depth ?? 0),
272
+ ROBAL_INSTRUCTIONS: instructions,
273
+ ...(task.feedback ? { ROBAL_FEEDBACK: task.feedback } : {}),
274
+ };
275
+ try {
276
+ const resultPromise = bridge.waitForResult();
277
+ let runResult;
278
+ if (opts.command) {
279
+ // Command mode: pipe instructions to the command
280
+ // Always wait for bridge result — ignore stdout
281
+ await new Promise((resolve, reject) => {
282
+ const child = require('child_process').spawn('bash', ['-c', opts.command], {
283
+ env: { ...process.env, ...env },
284
+ timeout: timeout,
285
+ });
286
+ child.stdin.write(env.ROBAL_INSTRUCTIONS);
287
+ child.stdin.end();
288
+ child.stdout.on('data', () => { });
289
+ child.stderr.on('data', () => { });
290
+ child.on('close', (code) => code === 0 ? resolve() : reject(new Error(`exit ${code}`)));
291
+ child.on('error', reject);
292
+ });
293
+ runResult = undefined;
294
+ }
295
+ else if (opts.run) {
296
+ runResult = await opts.run(task, env);
297
+ }
298
+ else {
299
+ throw new Error('Either command or run must be provided');
300
+ }
301
+ // If run() returned a string, use it directly (return mode)
302
+ if (typeof runResult === 'string') {
303
+ return { status: 'completed', output: runResult };
304
+ }
305
+ // Otherwise wait for agent to POST to /submit-result (bridge mode)
306
+ const timer = setTimeout(() => {
307
+ // Resolve with timeout error if agent never posts
308
+ bridge.resultResolve?.({ status: 'failed', output: '', error: `Agent did not submit result within ${timeout}ms` });
309
+ }, timeout);
310
+ const result = await resultPromise;
311
+ clearTimeout(timer);
312
+ return result;
313
+ }
314
+ catch (err) {
315
+ return { status: 'failed', output: '', error: err.message };
316
+ }
317
+ },
318
+ };
319
+ return { agent, bridge };
320
+ }
321
+ /**
322
+ * Creates a Reviewer that waits for an external process to POST to /submit-review.
323
+ */
324
+ function createReviewer(bridge) {
325
+ return {
326
+ reviewer: {
327
+ async review(task, output) {
328
+ bridge.setTask({ ...task, prompt: `Review: ${task.prompt}\n\nOutput: ${output.output}` });
329
+ return bridge.waitForReview();
330
+ },
331
+ },
332
+ };
333
+ }
334
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4JA,8CA4DC;AA6BD,kCAuFC;AAKD,wCAWC;A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AM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;YAC9D,CAAC;QACH,CAAC;KACF,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAmB;IAGhD,OAAO;QACL,QAAQ,EAAE;YACR,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM;gBACvB,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,WAAW,IAAI,CAAC,MAAM,eAAe,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC1F,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC;YAChC,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
package/dist/team.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { TeamConfig, TaskInput, TaskOutput, OrchestratorEvent, Agent } from './types';
2
+ export declare class Team {
3
+ readonly id: string;
4
+ readonly name: string;
5
+ private config;
6
+ private emit;
7
+ constructor(id: string, config: TeamConfig, emit: (event: OrchestratorEvent) => void);
8
+ /** Run a single task through this team's agent + review cycle. */
9
+ run(prompt: string, context?: TaskInput['context']): Promise<TaskOutput>;
10
+ /** Delegate subtasks to parallel child workers under this team. Optionally pass a different agent per subtask. */
11
+ delegate(subtasks: {
12
+ prompt: string;
13
+ name?: string;
14
+ agent?: Agent;
15
+ }[], parentPrompt: string, context?: TaskInput['context']): Promise<string[]>;
16
+ }
17
+ //# sourceMappingURL=team.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.d.ts","sourceRoot":"","sources":["../src/team.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAe,iBAAiB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKxG,qBAAa,IAAI;IACf,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,IAAI,CAAqC;gBAErC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI;IAOpF,kEAAkE;IAC5D,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA6B9E,kHAAkH;IAC5G,QAAQ,CAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAkBtJ"}