opc-agent 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +603 -545
  2. package/dist/channels/voice.d.ts +59 -0
  3. package/dist/channels/voice.js +351 -1
  4. package/dist/cli.js +172 -1
  5. package/dist/core/agent.d.ts +4 -0
  6. package/dist/core/agent.js +35 -0
  7. package/dist/core/collaboration.d.ts +89 -0
  8. package/dist/core/collaboration.js +201 -0
  9. package/dist/deploy/index.d.ts +40 -0
  10. package/dist/deploy/index.js +261 -0
  11. package/dist/index.d.ts +7 -1
  12. package/dist/index.js +47 -3
  13. package/dist/mcp/servers/calculator-mcp.d.ts +3 -0
  14. package/dist/mcp/servers/calculator-mcp.js +65 -0
  15. package/dist/mcp/servers/crypto-mcp.d.ts +3 -0
  16. package/dist/mcp/servers/crypto-mcp.js +108 -0
  17. package/dist/mcp/servers/database-mcp.d.ts +3 -0
  18. package/dist/mcp/servers/database-mcp.js +73 -0
  19. package/dist/mcp/servers/datetime-mcp.d.ts +3 -0
  20. package/dist/mcp/servers/datetime-mcp.js +71 -0
  21. package/dist/mcp/servers/filesystem.d.ts +3 -0
  22. package/dist/mcp/servers/filesystem.js +101 -0
  23. package/dist/mcp/servers/github-mcp.d.ts +3 -0
  24. package/dist/mcp/servers/github-mcp.js +60 -0
  25. package/dist/mcp/servers/index.d.ts +21 -0
  26. package/dist/mcp/servers/index.js +50 -0
  27. package/dist/mcp/servers/json-mcp.d.ts +3 -0
  28. package/dist/mcp/servers/json-mcp.js +126 -0
  29. package/dist/mcp/servers/memory-mcp.d.ts +3 -0
  30. package/dist/mcp/servers/memory-mcp.js +60 -0
  31. package/dist/mcp/servers/regex-mcp.d.ts +3 -0
  32. package/dist/mcp/servers/regex-mcp.js +56 -0
  33. package/dist/mcp/servers/web-mcp.d.ts +3 -0
  34. package/dist/mcp/servers/web-mcp.js +51 -0
  35. package/dist/schema/oad.d.ts +292 -12
  36. package/dist/schema/oad.js +12 -1
  37. package/dist/security/guardrails.d.ts +50 -0
  38. package/dist/security/guardrails.js +197 -0
  39. package/dist/studio/server.d.ts +31 -1
  40. package/dist/studio/server.js +154 -3
  41. package/dist/studio-ui/index.html +1278 -662
  42. package/dist/tools/integrations/calendar.d.ts +3 -0
  43. package/dist/tools/integrations/calendar.js +73 -0
  44. package/dist/tools/integrations/code-exec.d.ts +3 -0
  45. package/dist/tools/integrations/code-exec.js +42 -0
  46. package/dist/tools/integrations/csv-analyzer.d.ts +3 -0
  47. package/dist/tools/integrations/csv-analyzer.js +142 -0
  48. package/dist/tools/integrations/database.d.ts +3 -0
  49. package/dist/tools/integrations/database.js +44 -0
  50. package/dist/tools/integrations/email-send.d.ts +3 -0
  51. package/dist/tools/integrations/email-send.js +104 -0
  52. package/dist/tools/integrations/git-tool.d.ts +3 -0
  53. package/dist/tools/integrations/git-tool.js +49 -0
  54. package/dist/tools/integrations/github-tool.d.ts +3 -0
  55. package/dist/tools/integrations/github-tool.js +77 -0
  56. package/dist/tools/integrations/image-gen.d.ts +3 -0
  57. package/dist/tools/integrations/image-gen.js +58 -0
  58. package/dist/tools/integrations/index.d.ts +30 -0
  59. package/dist/tools/integrations/index.js +107 -0
  60. package/dist/tools/integrations/jira.d.ts +3 -0
  61. package/dist/tools/integrations/jira.js +85 -0
  62. package/dist/tools/integrations/notion.d.ts +3 -0
  63. package/dist/tools/integrations/notion.js +71 -0
  64. package/dist/tools/integrations/npm-tool.d.ts +3 -0
  65. package/dist/tools/integrations/npm-tool.js +49 -0
  66. package/dist/tools/integrations/pdf-reader.d.ts +3 -0
  67. package/dist/tools/integrations/pdf-reader.js +91 -0
  68. package/dist/tools/integrations/slack.d.ts +3 -0
  69. package/dist/tools/integrations/slack.js +67 -0
  70. package/dist/tools/integrations/summarizer.d.ts +3 -0
  71. package/dist/tools/integrations/summarizer.js +49 -0
  72. package/dist/tools/integrations/translator.d.ts +3 -0
  73. package/dist/tools/integrations/translator.js +48 -0
  74. package/dist/tools/integrations/trello.d.ts +3 -0
  75. package/dist/tools/integrations/trello.js +60 -0
  76. package/dist/tools/integrations/vector-search.d.ts +3 -0
  77. package/dist/tools/integrations/vector-search.js +44 -0
  78. package/dist/tools/integrations/web-scraper.d.ts +3 -0
  79. package/dist/tools/integrations/web-scraper.js +48 -0
  80. package/dist/tools/integrations/web-search.d.ts +3 -0
  81. package/dist/tools/integrations/web-search.js +60 -0
  82. package/dist/tools/integrations/webhook.d.ts +3 -0
  83. package/dist/tools/integrations/webhook.js +39 -0
  84. package/dist/ui/components.d.ts +10 -0
  85. package/dist/ui/components.js +123 -0
  86. package/package.json +1 -1
  87. package/src/channels/voice.ts +365 -0
  88. package/src/cli.ts +176 -2
  89. package/src/core/agent.ts +38 -0
  90. package/src/core/collaboration.ts +275 -0
  91. package/src/deploy/index.ts +255 -0
  92. package/src/index.ts +21 -1
  93. package/src/mcp/servers/calculator-mcp.ts +65 -0
  94. package/src/mcp/servers/crypto-mcp.ts +73 -0
  95. package/src/mcp/servers/database-mcp.ts +72 -0
  96. package/src/mcp/servers/datetime-mcp.ts +69 -0
  97. package/src/mcp/servers/filesystem.ts +66 -0
  98. package/src/mcp/servers/github-mcp.ts +58 -0
  99. package/src/mcp/servers/index.ts +63 -0
  100. package/src/mcp/servers/json-mcp.ts +102 -0
  101. package/src/mcp/servers/memory-mcp.ts +56 -0
  102. package/src/mcp/servers/regex-mcp.ts +53 -0
  103. package/src/mcp/servers/web-mcp.ts +49 -0
  104. package/src/schema/oad.ts +13 -0
  105. package/src/security/guardrails.ts +248 -0
  106. package/src/studio/server.ts +166 -4
  107. package/src/studio-ui/index.html +1278 -662
  108. package/src/tools/integrations/calendar.ts +73 -0
  109. package/src/tools/integrations/code-exec.ts +39 -0
  110. package/src/tools/integrations/csv-analyzer.ts +92 -0
  111. package/src/tools/integrations/database.ts +44 -0
  112. package/src/tools/integrations/email-send.ts +76 -0
  113. package/src/tools/integrations/git-tool.ts +42 -0
  114. package/src/tools/integrations/github-tool.ts +76 -0
  115. package/src/tools/integrations/image-gen.ts +56 -0
  116. package/src/tools/integrations/index.ts +92 -0
  117. package/src/tools/integrations/jira.ts +83 -0
  118. package/src/tools/integrations/notion.ts +71 -0
  119. package/src/tools/integrations/npm-tool.ts +48 -0
  120. package/src/tools/integrations/pdf-reader.ts +58 -0
  121. package/src/tools/integrations/slack.ts +65 -0
  122. package/src/tools/integrations/summarizer.ts +49 -0
  123. package/src/tools/integrations/translator.ts +48 -0
  124. package/src/tools/integrations/trello.ts +60 -0
  125. package/src/tools/integrations/vector-search.ts +42 -0
  126. package/src/tools/integrations/web-scraper.ts +47 -0
  127. package/src/tools/integrations/web-search.ts +58 -0
  128. package/src/tools/integrations/webhook.ts +38 -0
  129. package/src/ui/components.ts +127 -0
  130. package/tests/brain-seed-extended.test.ts +490 -0
  131. package/tests/collaboration.test.ts +319 -0
  132. package/tests/deploy-and-dag.test.ts +196 -0
  133. package/tests/guardrails.test.ts +177 -0
  134. package/tests/integrations.test.ts +249 -0
  135. package/tests/mcp-servers.test.ts +260 -0
  136. package/tests/voice-enhanced.test.ts +169 -0
  137. package/dist/dtv/data.d.ts +0 -18
  138. package/dist/dtv/data.js +0 -25
  139. package/dist/dtv/trust.d.ts +0 -19
  140. package/dist/dtv/trust.js +0 -40
  141. package/dist/dtv/value.d.ts +0 -23
  142. package/dist/dtv/value.js +0 -38
  143. package/dist/marketplace/index.d.ts +0 -34
  144. package/dist/marketplace/index.js +0 -202
@@ -8,6 +8,7 @@ const auto_learn_1 = require("../skills/auto-learn");
8
8
  const mcp_1 = require("../tools/mcp");
9
9
  const subagent_1 = require("./subagent");
10
10
  const seed_loader_1 = require("../memory/seed-loader");
11
+ const guardrails_1 = require("../security/guardrails");
11
12
  class BaseAgent extends events_1.EventEmitter {
12
13
  name;
13
14
  _state = 'init';
@@ -27,6 +28,7 @@ class BaseAgent extends events_1.EventEmitter {
27
28
  tracer;
28
29
  brainSeedConfig;
29
30
  agentDir;
31
+ guardrails;
30
32
  constructor(options) {
31
33
  super();
32
34
  this.name = options.name;
@@ -56,6 +58,12 @@ class BaseAgent extends events_1.EventEmitter {
56
58
  };
57
59
  }
58
60
  }
61
+ setGuardrails(config) {
62
+ this.guardrails = new guardrails_1.GuardrailManager(config);
63
+ }
64
+ getGuardrails() {
65
+ return this.guardrails;
66
+ }
59
67
  getLongTermMemory() {
60
68
  return this.longTermMemory;
61
69
  }
@@ -163,6 +171,23 @@ class BaseAgent extends events_1.EventEmitter {
163
171
  }
164
172
  const sessionId = message.metadata?.sessionId ?? 'default';
165
173
  await this.memory.addMessage(sessionId, message);
174
+ // === Guardrails: check input ===
175
+ if (this.guardrails) {
176
+ const inputCheck = await this.guardrails.checkInput(message.content);
177
+ if (inputCheck.blocked) {
178
+ const blockedResponse = this.createResponse(inputCheck.message ?? 'Message blocked by guardrails.', message);
179
+ await this.memory.addMessage(sessionId, blockedResponse);
180
+ this.emit('message:out', blockedResponse);
181
+ if (rootSpan && this.tracer) {
182
+ this.tracer.addEvent(rootSpan, 'guardrail.blocked', { rule: inputCheck.violations[0]?.rule ?? 'unknown' });
183
+ this.tracer.endSpan(rootSpan, 'ok');
184
+ }
185
+ return blockedResponse;
186
+ }
187
+ if (inputCheck.redacted && inputCheck.redactedText) {
188
+ message = { ...message, content: inputCheck.redactedText };
189
+ }
190
+ }
166
191
  // === Recall from long-term memory ===
167
192
  let memoryContext = '';
168
193
  if (this.longTermMemory && this.longTermMemoryConfig.autoRecall) {
@@ -278,6 +303,16 @@ class BaseAgent extends events_1.EventEmitter {
278
303
  timestamp: Date.now(),
279
304
  });
280
305
  }
306
+ // === Guardrails: check output ===
307
+ if (this.guardrails) {
308
+ const outputCheck = await this.guardrails.checkOutput(finalResponse);
309
+ if (outputCheck.blocked) {
310
+ finalResponse = outputCheck.message ?? 'Response blocked by guardrails.';
311
+ }
312
+ else if (outputCheck.redacted && outputCheck.redactedText) {
313
+ finalResponse = outputCheck.redactedText;
314
+ }
315
+ }
281
316
  const response = this.createResponse(finalResponse, message);
282
317
  await this.memory.addMessage(sessionId, response);
283
318
  this.emit('message:out', response);
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Multi-agent collaboration patterns
3
+ * @module core/collaboration
4
+ */
5
+ import type { BaseAgent } from './agent';
6
+ import type { Message } from './types';
7
+ export interface DebateArgument {
8
+ agent: string;
9
+ round: number;
10
+ argument: string;
11
+ }
12
+ export interface DebateResult {
13
+ topic: string;
14
+ rounds: DebateArgument[];
15
+ summary: string;
16
+ judge?: string;
17
+ }
18
+ export interface VoteEntry {
19
+ agent: string;
20
+ choice: string;
21
+ confidence: number;
22
+ }
23
+ export interface VoteResult {
24
+ question: string;
25
+ votes: VoteEntry[];
26
+ winner: string;
27
+ tally: Record<string, number>;
28
+ }
29
+ export interface PipelineStageResult {
30
+ agent: string;
31
+ input: string;
32
+ output: string;
33
+ durationMs: number;
34
+ }
35
+ export interface PipelineResult {
36
+ stages: PipelineStageResult[];
37
+ finalOutput: string;
38
+ totalDurationMs: number;
39
+ }
40
+ export interface WorkerResult {
41
+ agent: string;
42
+ subtask: string;
43
+ result: string;
44
+ }
45
+ export interface HierarchyResult {
46
+ task: string;
47
+ subtasks: WorkerResult[];
48
+ synthesis: string;
49
+ }
50
+ export declare class DebatePattern {
51
+ private agents;
52
+ private rounds;
53
+ constructor(agents: BaseAgent[], rounds?: number);
54
+ debate(topic: string, judgeAgent?: BaseAgent): Promise<DebateResult>;
55
+ }
56
+ export declare class VotingPattern {
57
+ private agents;
58
+ constructor(agents: BaseAgent[]);
59
+ vote(question: string, options: string[]): Promise<VoteResult>;
60
+ weightedVote(question: string, options: string[]): Promise<VoteResult>;
61
+ private tallyVotes;
62
+ }
63
+ export declare class PipelinePattern {
64
+ private stages;
65
+ constructor(stages: {
66
+ agent: BaseAgent;
67
+ transform?: (input: string) => string;
68
+ }[]);
69
+ process(input: string): Promise<PipelineResult>;
70
+ }
71
+ export declare class HierarchyPattern {
72
+ private leader;
73
+ private workers;
74
+ constructor(leader: BaseAgent, workers: BaseAgent[]);
75
+ execute(task: string): Promise<HierarchyResult>;
76
+ }
77
+ export declare class SharedContext {
78
+ private store;
79
+ private listeners;
80
+ set(key: string, value: any): void;
81
+ get<T>(key: string): T | undefined;
82
+ getAll(): Record<string, any>;
83
+ onChange(key: string, callback: (value: any) => void): void;
84
+ }
85
+ export declare class ConversationProtocol {
86
+ roundRobin(agents: BaseAgent[], topic: string, rounds: number): Promise<Message[]>;
87
+ moderated(agents: BaseAgent[], moderator: BaseAgent, topic: string): Promise<Message[]>;
88
+ }
89
+ //# sourceMappingURL=collaboration.d.ts.map
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ /**
3
+ * Multi-agent collaboration patterns
4
+ * @module core/collaboration
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ConversationProtocol = exports.SharedContext = exports.HierarchyPattern = exports.PipelinePattern = exports.VotingPattern = exports.DebatePattern = void 0;
8
+ // ─── Helper ─────────────────────────────────────────────────
9
+ function makeMsg(role, content) {
10
+ return { id: `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, role, content, timestamp: Date.now() };
11
+ }
12
+ async function agentChat(agent, prompt) {
13
+ const response = await agent.handleMessage(makeMsg('user', prompt));
14
+ return response.content;
15
+ }
16
+ // ─── DebatePattern ──────────────────────────────────────────
17
+ class DebatePattern {
18
+ agents;
19
+ rounds;
20
+ constructor(agents, rounds = 3) {
21
+ this.agents = agents;
22
+ this.rounds = rounds;
23
+ }
24
+ async debate(topic, judgeAgent) {
25
+ const allArgs = [];
26
+ let context = '';
27
+ for (let round = 1; round <= this.rounds; round++) {
28
+ for (const agent of this.agents) {
29
+ const prompt = round === 1
30
+ ? `Debate topic: "${topic}". Present your argument.`
31
+ : `Debate topic: "${topic}". Previous arguments:\n${context}\nPresent your counter-argument for round ${round}.`;
32
+ const argument = await agentChat(agent, prompt);
33
+ allArgs.push({ agent: agent.name, round, argument });
34
+ context += `\n[${agent.name} round ${round}]: ${argument}`;
35
+ }
36
+ }
37
+ const judge = judgeAgent ?? this.agents[0];
38
+ const summaryPrompt = `You are the judge. Summarize and decide the winner of this debate on "${topic}":\n${context}`;
39
+ const summary = await agentChat(judge, summaryPrompt);
40
+ return { topic, rounds: allArgs, summary, judge: judge.name };
41
+ }
42
+ }
43
+ exports.DebatePattern = DebatePattern;
44
+ // ─── VotingPattern ──────────────────────────────────────────
45
+ class VotingPattern {
46
+ agents;
47
+ constructor(agents) {
48
+ this.agents = agents;
49
+ }
50
+ async vote(question, options) {
51
+ const votes = [];
52
+ const optionList = options.map((o, i) => `${i + 1}. ${o}`).join('\n');
53
+ for (const agent of this.agents) {
54
+ const prompt = `Question: "${question}"\nOptions:\n${optionList}\nRespond with ONLY the exact text of your chosen option.`;
55
+ const raw = await agentChat(agent, prompt);
56
+ const choice = options.find(o => raw.includes(o)) ?? raw.trim();
57
+ votes.push({ agent: agent.name, choice, confidence: 1 });
58
+ }
59
+ return this.tallyVotes(question, votes);
60
+ }
61
+ async weightedVote(question, options) {
62
+ const votes = [];
63
+ const optionList = options.map((o, i) => `${i + 1}. ${o}`).join('\n');
64
+ for (const agent of this.agents) {
65
+ const prompt = `Question: "${question}"\nOptions:\n${optionList}\nRespond in format: CHOICE|CONFIDENCE(0-1)`;
66
+ const raw = await agentChat(agent, prompt);
67
+ const parts = raw.split('|');
68
+ const choiceRaw = parts[0]?.trim() ?? '';
69
+ const choice = options.find(o => choiceRaw.includes(o)) ?? choiceRaw;
70
+ const confidence = Math.min(1, Math.max(0, parseFloat(parts[1] ?? '0.5') || 0.5));
71
+ votes.push({ agent: agent.name, choice, confidence });
72
+ }
73
+ return this.tallyVotes(question, votes);
74
+ }
75
+ tallyVotes(question, votes) {
76
+ const tally = {};
77
+ for (const v of votes) {
78
+ tally[v.choice] = (tally[v.choice] ?? 0) + v.confidence;
79
+ }
80
+ const winner = Object.entries(tally).sort((a, b) => b[1] - a[1])[0]?.[0] ?? '';
81
+ return { question, votes, winner, tally };
82
+ }
83
+ }
84
+ exports.VotingPattern = VotingPattern;
85
+ // ─── PipelinePattern ────────────────────────────────────────
86
+ class PipelinePattern {
87
+ stages;
88
+ constructor(stages) {
89
+ this.stages = stages;
90
+ }
91
+ async process(input) {
92
+ const stageResults = [];
93
+ let current = input;
94
+ const t0 = Date.now();
95
+ for (const stage of this.stages) {
96
+ const stageInput = stage.transform ? stage.transform(current) : current;
97
+ const start = Date.now();
98
+ const output = await agentChat(stage.agent, stageInput);
99
+ stageResults.push({ agent: stage.agent.name, input: stageInput, output, durationMs: Date.now() - start });
100
+ current = output;
101
+ }
102
+ return { stages: stageResults, finalOutput: current, totalDurationMs: Date.now() - t0 };
103
+ }
104
+ }
105
+ exports.PipelinePattern = PipelinePattern;
106
+ // ─── HierarchyPattern ───────────────────────────────────────
107
+ class HierarchyPattern {
108
+ leader;
109
+ workers;
110
+ constructor(leader, workers) {
111
+ this.leader = leader;
112
+ this.workers = workers;
113
+ }
114
+ async execute(task) {
115
+ // Leader decomposes
116
+ const decomposePrompt = `Decompose this task into ${this.workers.length} subtasks (one per line, no numbering): "${task}"`;
117
+ const decomposition = await agentChat(this.leader, decomposePrompt);
118
+ const subtasks = decomposition.split('\n').map(s => s.trim()).filter(Boolean);
119
+ // Workers execute in parallel
120
+ const workerResults = await Promise.all(this.workers.map(async (worker, i) => {
121
+ const subtask = subtasks[i] ?? subtasks[subtasks.length - 1] ?? task;
122
+ const result = await agentChat(worker, `Complete this subtask: "${subtask}"`);
123
+ return { agent: worker.name, subtask, result };
124
+ }));
125
+ // Leader synthesizes
126
+ const synthPrompt = `Original task: "${task}"\nSubtask results:\n${workerResults.map(r => `[${r.agent}] ${r.subtask}: ${r.result}`).join('\n')}\nSynthesize a final answer.`;
127
+ const synthesis = await agentChat(this.leader, synthPrompt);
128
+ return { task, subtasks: workerResults, synthesis };
129
+ }
130
+ }
131
+ exports.HierarchyPattern = HierarchyPattern;
132
+ // ─── SharedContext ───────────────────────────────────────────
133
+ class SharedContext {
134
+ store = new Map();
135
+ listeners = new Map();
136
+ set(key, value) {
137
+ this.store.set(key, value);
138
+ const cbs = this.listeners.get(key);
139
+ if (cbs)
140
+ cbs.forEach(cb => cb(value));
141
+ }
142
+ get(key) {
143
+ return this.store.get(key);
144
+ }
145
+ getAll() {
146
+ const result = {};
147
+ for (const [k, v] of this.store)
148
+ result[k] = v;
149
+ return result;
150
+ }
151
+ onChange(key, callback) {
152
+ const existing = this.listeners.get(key) ?? [];
153
+ existing.push(callback);
154
+ this.listeners.set(key, existing);
155
+ }
156
+ }
157
+ exports.SharedContext = SharedContext;
158
+ // ─── ConversationProtocol ───────────────────────────────────
159
+ class ConversationProtocol {
160
+ async roundRobin(agents, topic, rounds) {
161
+ const messages = [];
162
+ let context = `Topic: "${topic}"`;
163
+ for (let round = 0; round < rounds; round++) {
164
+ for (const agent of agents) {
165
+ const prompt = `${context}\n\nIt's your turn to contribute to this discussion. Be concise.`;
166
+ const content = await agentChat(agent, prompt);
167
+ const msg = makeMsg('assistant', content);
168
+ msg.agent = agent.name;
169
+ messages.push(msg);
170
+ context += `\n[${agent.name}]: ${content}`;
171
+ }
172
+ }
173
+ return messages;
174
+ }
175
+ async moderated(agents, moderator, topic) {
176
+ const messages = [];
177
+ let context = `Topic: "${topic}"`;
178
+ // Moderator opens
179
+ const opening = await agentChat(moderator, `You are moderating a discussion on "${topic}". Introduce the topic and ask the first question.`);
180
+ const openMsg = makeMsg('assistant', opening);
181
+ openMsg.agent = moderator.name;
182
+ messages.push(openMsg);
183
+ context += `\n[Moderator ${moderator.name}]: ${opening}`;
184
+ // Each agent responds
185
+ for (const agent of agents) {
186
+ const content = await agentChat(agent, `${context}\n\nRespond to the moderator's question.`);
187
+ const msg = makeMsg('assistant', content);
188
+ msg.agent = agent.name;
189
+ messages.push(msg);
190
+ context += `\n[${agent.name}]: ${content}`;
191
+ }
192
+ // Moderator summarizes
193
+ const summary = await agentChat(moderator, `${context}\n\nSummarize the discussion and provide closing remarks.`);
194
+ const closeMsg = makeMsg('assistant', summary);
195
+ closeMsg.agent = moderator.name;
196
+ messages.push(closeMsg);
197
+ return messages;
198
+ }
199
+ }
200
+ exports.ConversationProtocol = ConversationProtocol;
201
+ //# sourceMappingURL=collaboration.js.map
@@ -0,0 +1,40 @@
1
+ export interface DeployOptions {
2
+ port?: number;
3
+ env?: Record<string, string>;
4
+ platform?: 'docker' | 'railway' | 'fly' | 'render';
5
+ replicas?: number;
6
+ }
7
+ export interface DeployResult {
8
+ platform: string;
9
+ success: boolean;
10
+ url?: string;
11
+ message: string;
12
+ files?: string[];
13
+ }
14
+ export declare class AgentDeployer {
15
+ /**
16
+ * Generate Dockerfile for the agent
17
+ */
18
+ generateDockerfile(agentDir: string, options?: DeployOptions): Promise<string>;
19
+ /**
20
+ * Generate docker-compose.yml
21
+ */
22
+ generateCompose(agentDir: string, options?: DeployOptions): Promise<string>;
23
+ /**
24
+ * Deploy to Railway (via CLI)
25
+ */
26
+ deployRailway(agentDir: string): Promise<DeployResult>;
27
+ /**
28
+ * Deploy to Fly.io
29
+ */
30
+ deployFly(agentDir: string): Promise<DeployResult>;
31
+ /**
32
+ * Deploy locally via Docker
33
+ */
34
+ deployLocal(agentDir: string, options?: DeployOptions): Promise<DeployResult>;
35
+ /**
36
+ * Generate deployment files without deploying
37
+ */
38
+ generateFiles(agentDir: string, options?: DeployOptions): Promise<DeployResult>;
39
+ }
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,261 @@
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.AgentDeployer = void 0;
37
+ /**
38
+ * AgentDeployer - Deploy agents to Docker, Railway, Fly.io
39
+ */
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const child_process_1 = require("child_process");
43
+ class AgentDeployer {
44
+ /**
45
+ * Generate Dockerfile for the agent
46
+ */
47
+ async generateDockerfile(agentDir, options) {
48
+ const port = options?.port || 3000;
49
+ const pkgPath = path.join(agentDir, 'package.json');
50
+ let startCmd = 'node src/index.js';
51
+ if (fs.existsSync(pkgPath)) {
52
+ try {
53
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
54
+ if (pkg.scripts?.start) {
55
+ startCmd = pkg.scripts.start;
56
+ }
57
+ if (pkg.main) {
58
+ startCmd = `node ${pkg.main}`;
59
+ }
60
+ }
61
+ catch { }
62
+ }
63
+ return `FROM node:22-slim
64
+ WORKDIR /app
65
+
66
+ # Install dependencies
67
+ COPY package*.json ./
68
+ RUN npm ci --production
69
+
70
+ # Copy source
71
+ COPY . .
72
+
73
+ # Build if needed
74
+ RUN if [ -f "tsconfig.json" ]; then npx tsc || true; fi
75
+
76
+ EXPOSE ${port}
77
+
78
+ ENV NODE_ENV=production
79
+ ENV PORT=${port}
80
+
81
+ CMD ["${startCmd.split(' ')[0]}", ${startCmd.split(' ').slice(1).map(s => `"${s}"`).join(', ')}]
82
+ `;
83
+ }
84
+ /**
85
+ * Generate docker-compose.yml
86
+ */
87
+ async generateCompose(agentDir, options) {
88
+ const port = options?.port || 3000;
89
+ const replicas = options?.replicas || 1;
90
+ const agentName = path.basename(agentDir).toLowerCase().replace(/[^a-z0-9-]/g, '-') || 'opc-agent';
91
+ const envLines = options?.env
92
+ ? Object.entries(options.env).map(([k, v]) => ` - ${k}=${v}`).join('\n')
93
+ : '';
94
+ return `version: "3.8"
95
+
96
+ services:
97
+ ${agentName}:
98
+ build: .
99
+ ports:
100
+ - "${port}:${port}"
101
+ environment:
102
+ - NODE_ENV=production
103
+ - PORT=${port}
104
+ ${envLines ? envLines + '\n' : ''} restart: unless-stopped
105
+ ${replicas > 1 ? ` deploy:\n replicas: ${replicas}` : ''}
106
+ volumes:
107
+ - agent-data:/app/data
108
+
109
+ volumes:
110
+ agent-data:
111
+ `;
112
+ }
113
+ /**
114
+ * Deploy to Railway (via CLI)
115
+ */
116
+ async deployRailway(agentDir) {
117
+ try {
118
+ (0, child_process_1.execSync)('railway version', { stdio: 'pipe' });
119
+ }
120
+ catch {
121
+ return { platform: 'railway', success: false, message: 'Railway CLI not installed. Run: npm i -g @railway/cli' };
122
+ }
123
+ try {
124
+ // Ensure Dockerfile exists
125
+ const dockerfilePath = path.join(agentDir, 'Dockerfile');
126
+ if (!fs.existsSync(dockerfilePath)) {
127
+ const content = await this.generateDockerfile(agentDir);
128
+ fs.writeFileSync(dockerfilePath, content);
129
+ }
130
+ const output = (0, child_process_1.execSync)('railway up --detach', { cwd: agentDir, encoding: 'utf-8' });
131
+ const urlMatch = output.match(/(https:\/\/[^\s]+)/);
132
+ return {
133
+ platform: 'railway',
134
+ success: true,
135
+ url: urlMatch?.[1],
136
+ message: 'Deployed to Railway successfully'
137
+ };
138
+ }
139
+ catch (e) {
140
+ return { platform: 'railway', success: false, message: e.message };
141
+ }
142
+ }
143
+ /**
144
+ * Deploy to Fly.io
145
+ */
146
+ async deployFly(agentDir) {
147
+ try {
148
+ (0, child_process_1.execSync)('fly version', { stdio: 'pipe' });
149
+ }
150
+ catch {
151
+ return { platform: 'fly', success: false, message: 'Fly CLI not installed. Run: curl -L https://fly.io/install.sh | sh' };
152
+ }
153
+ try {
154
+ const agentName = path.basename(agentDir).toLowerCase().replace(/[^a-z0-9-]/g, '-');
155
+ // Generate fly.toml if not exists
156
+ const flyTomlPath = path.join(agentDir, 'fly.toml');
157
+ if (!fs.existsSync(flyTomlPath)) {
158
+ fs.writeFileSync(flyTomlPath, `app = "${agentName}"
159
+ primary_region = "sjc"
160
+
161
+ [build]
162
+
163
+ [http_service]
164
+ internal_port = 3000
165
+ force_https = true
166
+ auto_stop_machines = true
167
+ auto_start_machines = true
168
+
169
+ [checks]
170
+ [checks.alive]
171
+ type = "tcp"
172
+ port = 3000
173
+ `);
174
+ }
175
+ // Ensure Dockerfile exists
176
+ const dockerfilePath = path.join(agentDir, 'Dockerfile');
177
+ if (!fs.existsSync(dockerfilePath)) {
178
+ const content = await this.generateDockerfile(agentDir);
179
+ fs.writeFileSync(dockerfilePath, content);
180
+ }
181
+ const output = (0, child_process_1.execSync)('fly deploy', { cwd: agentDir, encoding: 'utf-8' });
182
+ return {
183
+ platform: 'fly',
184
+ success: true,
185
+ url: `https://${agentName}.fly.dev`,
186
+ message: 'Deployed to Fly.io successfully'
187
+ };
188
+ }
189
+ catch (e) {
190
+ return { platform: 'fly', success: false, message: e.message };
191
+ }
192
+ }
193
+ /**
194
+ * Deploy locally via Docker
195
+ */
196
+ async deployLocal(agentDir, options) {
197
+ try {
198
+ (0, child_process_1.execSync)('docker version', { stdio: 'pipe' });
199
+ }
200
+ catch {
201
+ return { platform: 'docker', success: false, message: 'Docker not installed or not running' };
202
+ }
203
+ const files = [];
204
+ // Generate Dockerfile
205
+ const dockerfilePath = path.join(agentDir, 'Dockerfile');
206
+ if (!fs.existsSync(dockerfilePath)) {
207
+ fs.writeFileSync(dockerfilePath, await this.generateDockerfile(agentDir, options));
208
+ files.push('Dockerfile');
209
+ }
210
+ // Generate docker-compose.yml
211
+ const composePath = path.join(agentDir, 'docker-compose.yml');
212
+ if (!fs.existsSync(composePath)) {
213
+ fs.writeFileSync(composePath, await this.generateCompose(agentDir, options));
214
+ files.push('docker-compose.yml');
215
+ }
216
+ try {
217
+ (0, child_process_1.execSync)('docker compose up -d --build', { cwd: agentDir, stdio: 'inherit' });
218
+ const port = options?.port || 3000;
219
+ return {
220
+ platform: 'docker',
221
+ success: true,
222
+ url: `http://localhost:${port}`,
223
+ message: 'Running locally via Docker',
224
+ files
225
+ };
226
+ }
227
+ catch (e) {
228
+ return { platform: 'docker', success: false, message: e.message, files };
229
+ }
230
+ }
231
+ /**
232
+ * Generate deployment files without deploying
233
+ */
234
+ async generateFiles(agentDir, options) {
235
+ const files = [];
236
+ const port = options?.port || 3000;
237
+ const dockerfile = await this.generateDockerfile(agentDir, options);
238
+ fs.writeFileSync(path.join(agentDir, 'Dockerfile'), dockerfile);
239
+ files.push('Dockerfile');
240
+ const compose = await this.generateCompose(agentDir, options);
241
+ fs.writeFileSync(path.join(agentDir, 'docker-compose.yml'), compose);
242
+ files.push('docker-compose.yml');
243
+ // Generate .dockerignore
244
+ const dockerignore = `node_modules
245
+ .git
246
+ .env
247
+ *.log
248
+ dist
249
+ `;
250
+ fs.writeFileSync(path.join(agentDir, '.dockerignore'), dockerignore);
251
+ files.push('.dockerignore');
252
+ return {
253
+ platform: 'docker',
254
+ success: true,
255
+ message: `Generated ${files.length} deployment files`,
256
+ files,
257
+ };
258
+ }
259
+ }
260
+ exports.AgentDeployer = AgentDeployer;
261
+ //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -35,7 +35,8 @@ export type { A2ARequest, A2AResponse, AgentCapability, AgentRegistration, Agent
35
35
  export { HITLManager } from './core/hitl';
36
36
  export type { ApprovalRequest, ApprovalResponse, HITLConfig } from './core/hitl';
37
37
  export { VoiceChannel } from './channels/voice';
38
- export type { VoiceChannelConfig, STTProvider, TTSProvider } from './channels/voice';
38
+ export type { VoiceChannelConfig, STTProvider, TTSProvider, VoiceConfig } from './channels/voice';
39
+ export { WhisperSTTProvider, DeepgramSTTProvider, EdgeTTSProvider, OpenAITTSProvider, ElevenLabsTTSProvider, createVoiceProviders } from './channels/voice';
39
40
  export { WebhookChannel } from './channels/webhook';
40
41
  export type { WebhookConfig, WebhookPayload } from './channels/webhook';
41
42
  export { VersionManager } from './core/versioning';
@@ -90,6 +91,8 @@ export type { PluginManifest, Plugin } from './plugins';
90
91
  export { loggerPlugin } from './plugins/logger';
91
92
  export { rateLimiterPlugin, createRateLimiterPlugin as createEnhancedRateLimiterPlugin } from './plugins/rate-limiter';
92
93
  export { contentFilterPlugin, createContentFilterPlugin } from './plugins/content-filter';
94
+ export { GuardrailManager, createGuardrailsFromConfig } from './security/guardrails';
95
+ export type { GuardrailConfig, GuardrailRule, GuardrailResult, GuardrailViolation } from './security/guardrails';
93
96
  export { FeishuChannel } from './channels/feishu';
94
97
  export type { FeishuChannelConfig } from './channels/feishu';
95
98
  export { DiscordChannel } from './channels/discord';
@@ -124,5 +127,8 @@ export { AgentEvaluator } from './eval';
124
127
  export type { EvalCase, EvalResult, EvalSuite, EvalReport } from './eval';
125
128
  export { AGUIServer, AGUIEventEmitter, AGUIClient } from './protocols/agui';
126
129
  export { AGUI_EVENT_TYPES, isValidEventType } from './protocols/agui';
130
+ export { DebatePattern, VotingPattern, PipelinePattern, HierarchyPattern, SharedContext, ConversationProtocol } from './core/collaboration';
131
+ export type { DebateResult, DebateArgument, VoteResult, VoteEntry, PipelineResult, PipelineStageResult, HierarchyResult, WorkerResult } from './core/collaboration';
127
132
  export type { AGUIEvent, AGUIEventType, AGUIMessage, AGUIRunRequest, AGUIToolCall, AGUIToolDefinition, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, StateSnapshotEvent, StateDeltaEvent, MessagesSnapshotEvent, RunStartedEvent, RunFinishedEvent, RunErrorEvent, StepStartedEvent, StepFinishedEvent, CustomEvent, } from './protocols/agui';
133
+ export { SlackTool, EmailSendTool, WebhookTool, NotionTool, GitHubTool, JiraTool, CalendarTool, TrelloTool, WebSearchTool, WebScraperTool, DatabaseTool, VectorSearchTool, CodeExecutionTool, GitTool, NpmTool, ImageGenerationTool, PDFReaderTool, CSVAnalyzerTool, SummarizerTool, TranslatorTool, getAllIntegrationTools, getIntegrationTool, } from './tools/integrations';
128
134
  //# sourceMappingURL=index.d.ts.map