@jackchen_me/open-multi-agent 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.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -0
  3. package/dist/agent/agent.d.ts +121 -0
  4. package/dist/agent/agent.d.ts.map +1 -0
  5. package/dist/agent/agent.js +294 -0
  6. package/dist/agent/agent.js.map +1 -0
  7. package/dist/agent/pool.d.ts +128 -0
  8. package/dist/agent/pool.d.ts.map +1 -0
  9. package/dist/agent/pool.js +236 -0
  10. package/dist/agent/pool.js.map +1 -0
  11. package/dist/agent/runner.d.ts +120 -0
  12. package/dist/agent/runner.d.ts.map +1 -0
  13. package/dist/agent/runner.js +274 -0
  14. package/dist/agent/runner.js.map +1 -0
  15. package/dist/index.d.ts +73 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +87 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/llm/adapter.d.ts +38 -0
  20. package/dist/llm/adapter.d.ts.map +1 -0
  21. package/dist/llm/adapter.js +46 -0
  22. package/dist/llm/adapter.js.map +1 -0
  23. package/dist/llm/anthropic.d.ts +56 -0
  24. package/dist/llm/anthropic.d.ts.map +1 -0
  25. package/dist/llm/anthropic.js +307 -0
  26. package/dist/llm/anthropic.js.map +1 -0
  27. package/dist/llm/openai.d.ts +62 -0
  28. package/dist/llm/openai.d.ts.map +1 -0
  29. package/dist/llm/openai.js +424 -0
  30. package/dist/llm/openai.js.map +1 -0
  31. package/dist/memory/shared.d.ts +86 -0
  32. package/dist/memory/shared.d.ts.map +1 -0
  33. package/dist/memory/shared.js +155 -0
  34. package/dist/memory/shared.js.map +1 -0
  35. package/dist/memory/store.d.ts +64 -0
  36. package/dist/memory/store.d.ts.map +1 -0
  37. package/dist/memory/store.js +103 -0
  38. package/dist/memory/store.js.map +1 -0
  39. package/dist/orchestrator/orchestrator.d.ts +173 -0
  40. package/dist/orchestrator/orchestrator.d.ts.map +1 -0
  41. package/dist/orchestrator/orchestrator.js +698 -0
  42. package/dist/orchestrator/orchestrator.js.map +1 -0
  43. package/dist/orchestrator/scheduler.d.ts +112 -0
  44. package/dist/orchestrator/scheduler.d.ts.map +1 -0
  45. package/dist/orchestrator/scheduler.js +282 -0
  46. package/dist/orchestrator/scheduler.js.map +1 -0
  47. package/dist/task/queue.d.ts +160 -0
  48. package/dist/task/queue.d.ts.map +1 -0
  49. package/dist/task/queue.js +337 -0
  50. package/dist/task/queue.js.map +1 -0
  51. package/dist/task/task.d.ts +86 -0
  52. package/dist/task/task.d.ts.map +1 -0
  53. package/dist/task/task.js +201 -0
  54. package/dist/task/task.js.map +1 -0
  55. package/dist/team/messaging.d.ts +106 -0
  56. package/dist/team/messaging.d.ts.map +1 -0
  57. package/dist/team/messaging.js +182 -0
  58. package/dist/team/messaging.js.map +1 -0
  59. package/dist/team/team.d.ts +141 -0
  60. package/dist/team/team.d.ts.map +1 -0
  61. package/dist/team/team.js +282 -0
  62. package/dist/team/team.js.map +1 -0
  63. package/dist/tool/built-in/bash.d.ts +12 -0
  64. package/dist/tool/built-in/bash.d.ts.map +1 -0
  65. package/dist/tool/built-in/bash.js +133 -0
  66. package/dist/tool/built-in/bash.js.map +1 -0
  67. package/dist/tool/built-in/file-edit.d.ts +14 -0
  68. package/dist/tool/built-in/file-edit.d.ts.map +1 -0
  69. package/dist/tool/built-in/file-edit.js +130 -0
  70. package/dist/tool/built-in/file-edit.js.map +1 -0
  71. package/dist/tool/built-in/file-read.d.ts +12 -0
  72. package/dist/tool/built-in/file-read.d.ts.map +1 -0
  73. package/dist/tool/built-in/file-read.js +82 -0
  74. package/dist/tool/built-in/file-read.js.map +1 -0
  75. package/dist/tool/built-in/file-write.d.ts +11 -0
  76. package/dist/tool/built-in/file-write.d.ts.map +1 -0
  77. package/dist/tool/built-in/file-write.js +70 -0
  78. package/dist/tool/built-in/file-write.js.map +1 -0
  79. package/dist/tool/built-in/grep.d.ts +15 -0
  80. package/dist/tool/built-in/grep.d.ts.map +1 -0
  81. package/dist/tool/built-in/grep.js +287 -0
  82. package/dist/tool/built-in/grep.js.map +1 -0
  83. package/dist/tool/built-in/index.d.ts +36 -0
  84. package/dist/tool/built-in/index.d.ts.map +1 -0
  85. package/dist/tool/built-in/index.js +45 -0
  86. package/dist/tool/built-in/index.js.map +1 -0
  87. package/dist/tool/executor.d.ts +71 -0
  88. package/dist/tool/executor.d.ts.map +1 -0
  89. package/dist/tool/executor.js +116 -0
  90. package/dist/tool/executor.js.map +1 -0
  91. package/dist/tool/framework.d.ts +143 -0
  92. package/dist/tool/framework.d.ts.map +1 -0
  93. package/dist/tool/framework.js +371 -0
  94. package/dist/tool/framework.js.map +1 -0
  95. package/dist/types.d.ts +285 -0
  96. package/dist/types.d.ts.map +1 -0
  97. package/dist/types.js +8 -0
  98. package/dist/types.js.map +1 -0
  99. package/dist/utils/semaphore.d.ts +47 -0
  100. package/dist/utils/semaphore.d.ts.map +1 -0
  101. package/dist/utils/semaphore.js +85 -0
  102. package/dist/utils/semaphore.js.map +1 -0
  103. package/examples/01-single-agent.ts +131 -0
  104. package/examples/02-team-collaboration.ts +167 -0
  105. package/examples/03-task-pipeline.ts +201 -0
  106. package/examples/04-multi-model-team.ts +261 -0
  107. package/package.json +49 -0
  108. package/src/agent/agent.ts +364 -0
  109. package/src/agent/pool.ts +278 -0
  110. package/src/agent/runner.ts +413 -0
  111. package/src/index.ts +166 -0
  112. package/src/llm/adapter.ts +74 -0
  113. package/src/llm/anthropic.ts +388 -0
  114. package/src/llm/openai.ts +522 -0
  115. package/src/memory/shared.ts +181 -0
  116. package/src/memory/store.ts +124 -0
  117. package/src/orchestrator/orchestrator.ts +851 -0
  118. package/src/orchestrator/scheduler.ts +352 -0
  119. package/src/task/queue.ts +394 -0
  120. package/src/task/task.ts +232 -0
  121. package/src/team/messaging.ts +230 -0
  122. package/src/team/team.ts +334 -0
  123. package/src/tool/built-in/bash.ts +187 -0
  124. package/src/tool/built-in/file-edit.ts +154 -0
  125. package/src/tool/built-in/file-read.ts +105 -0
  126. package/src/tool/built-in/file-write.ts +81 -0
  127. package/src/tool/built-in/grep.ts +362 -0
  128. package/src/tool/built-in/index.ts +50 -0
  129. package/src/tool/executor.ts +178 -0
  130. package/src/tool/framework.ts +557 -0
  131. package/src/types.ts +362 -0
  132. package/src/utils/semaphore.ts +89 -0
  133. package/tsconfig.json +25 -0
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @fileoverview Inter-agent message bus.
3
+ *
4
+ * Provides a lightweight pub/sub system so agents can exchange typed messages
5
+ * without direct references to each other. All messages are retained in memory
6
+ * for replay and audit; read-state is tracked per recipient.
7
+ */
8
+ /** A single message exchanged between agents (or broadcast to all). */
9
+ export interface Message {
10
+ /** Stable UUID for this message. */
11
+ readonly id: string;
12
+ /** Name of the sending agent. */
13
+ readonly from: string;
14
+ /**
15
+ * Recipient agent name, or `'*'` when the message is a broadcast intended
16
+ * for every agent except the sender.
17
+ */
18
+ readonly to: string;
19
+ readonly content: string;
20
+ readonly timestamp: Date;
21
+ }
22
+ /**
23
+ * In-memory message bus for inter-agent communication.
24
+ *
25
+ * Agents can send point-to-point messages or broadcasts. Subscribers are
26
+ * notified synchronously (within the same microtask) when a new message
27
+ * arrives addressed to them.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const bus = new MessageBus()
32
+ *
33
+ * const unsubscribe = bus.subscribe('worker', (msg) => {
34
+ * console.log(`worker received: ${msg.content}`)
35
+ * })
36
+ *
37
+ * bus.send('coordinator', 'worker', 'Start task A')
38
+ * bus.broadcast('coordinator', 'All agents: stand by')
39
+ *
40
+ * unsubscribe()
41
+ * ```
42
+ */
43
+ export declare class MessageBus {
44
+ /** All messages ever sent, in insertion order. */
45
+ private readonly messages;
46
+ /**
47
+ * Per-agent set of message IDs that have already been marked as read.
48
+ * A message absent from this set is considered unread.
49
+ */
50
+ private readonly readState;
51
+ /**
52
+ * Active subscribers keyed by agent name. Each subscriber is a callback
53
+ * paired with a unique subscription ID used for unsubscription.
54
+ */
55
+ private readonly subscribers;
56
+ /**
57
+ * Send a message from `from` to `to`.
58
+ *
59
+ * @returns The persisted {@link Message} including its generated ID and timestamp.
60
+ */
61
+ send(from: string, to: string, content: string): Message;
62
+ /**
63
+ * Broadcast a message from `from` to all other agents (`to === '*'`).
64
+ *
65
+ * @returns The persisted broadcast {@link Message}.
66
+ */
67
+ broadcast(from: string, content: string): Message;
68
+ /**
69
+ * Returns messages that have not yet been marked as read by `agentName`,
70
+ * including both direct messages and broadcasts addressed to them.
71
+ */
72
+ getUnread(agentName: string): Message[];
73
+ /**
74
+ * Returns every message (read or unread) addressed to `agentName`,
75
+ * preserving insertion order.
76
+ */
77
+ getAll(agentName: string): Message[];
78
+ /**
79
+ * Mark a set of messages as read for `agentName`.
80
+ * Passing IDs that were already marked, or do not exist, is a no-op.
81
+ */
82
+ markRead(agentName: string, messageIds: string[]): void;
83
+ /**
84
+ * Returns all messages exchanged between `agent1` and `agent2` (in either
85
+ * direction), sorted chronologically.
86
+ */
87
+ getConversation(agent1: string, agent2: string): Message[];
88
+ /**
89
+ * Subscribe to new messages addressed to `agentName`.
90
+ *
91
+ * The `callback` is invoked synchronously after each matching message is
92
+ * persisted. Returns an unsubscribe function; calling it is idempotent.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const off = bus.subscribe('agent-b', (msg) => handleMessage(msg))
97
+ * // Later…
98
+ * off()
99
+ * ```
100
+ */
101
+ subscribe(agentName: string, callback: (message: Message) => void): () => void;
102
+ private persist;
103
+ private notifySubscribers;
104
+ private fireCallbacks;
105
+ }
106
+ //# sourceMappingURL=messaging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/team/messaging.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,uEAAuE;AACvE,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,iCAA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4
+ * Provides a lightweight pub/sub system so agents can exchange typed messages
5
+ * without direct references to each other. All messages are retained in memory
6
+ * for replay and audit; read-state is tracked per recipient.
7
+ */
8
+ // ---------------------------------------------------------------------------
9
+ // Internal helpers
10
+ // ---------------------------------------------------------------------------
11
+ /** Returns true when `message` is addressed to `agentName`. */
12
+ function isAddressedTo(message, agentName) {
13
+ if (message.to === '*') {
14
+ // Broadcasts are delivered to everyone except the sender.
15
+ return message.from !== agentName;
16
+ }
17
+ return message.to === agentName;
18
+ }
19
+ // ---------------------------------------------------------------------------
20
+ // MessageBus
21
+ // ---------------------------------------------------------------------------
22
+ /**
23
+ * In-memory message bus for inter-agent communication.
24
+ *
25
+ * Agents can send point-to-point messages or broadcasts. Subscribers are
26
+ * notified synchronously (within the same microtask) when a new message
27
+ * arrives addressed to them.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const bus = new MessageBus()
32
+ *
33
+ * const unsubscribe = bus.subscribe('worker', (msg) => {
34
+ * console.log(`worker received: ${msg.content}`)
35
+ * })
36
+ *
37
+ * bus.send('coordinator', 'worker', 'Start task A')
38
+ * bus.broadcast('coordinator', 'All agents: stand by')
39
+ *
40
+ * unsubscribe()
41
+ * ```
42
+ */
43
+ export class MessageBus {
44
+ /** All messages ever sent, in insertion order. */
45
+ messages = [];
46
+ /**
47
+ * Per-agent set of message IDs that have already been marked as read.
48
+ * A message absent from this set is considered unread.
49
+ */
50
+ readState = new Map();
51
+ /**
52
+ * Active subscribers keyed by agent name. Each subscriber is a callback
53
+ * paired with a unique subscription ID used for unsubscription.
54
+ */
55
+ subscribers = new Map();
56
+ // ---------------------------------------------------------------------------
57
+ // Write operations
58
+ // ---------------------------------------------------------------------------
59
+ /**
60
+ * Send a message from `from` to `to`.
61
+ *
62
+ * @returns The persisted {@link Message} including its generated ID and timestamp.
63
+ */
64
+ send(from, to, content) {
65
+ const message = {
66
+ id: crypto.randomUUID(),
67
+ from,
68
+ to,
69
+ content,
70
+ timestamp: new Date(),
71
+ };
72
+ this.persist(message);
73
+ return message;
74
+ }
75
+ /**
76
+ * Broadcast a message from `from` to all other agents (`to === '*'`).
77
+ *
78
+ * @returns The persisted broadcast {@link Message}.
79
+ */
80
+ broadcast(from, content) {
81
+ return this.send(from, '*', content);
82
+ }
83
+ // ---------------------------------------------------------------------------
84
+ // Read operations
85
+ // ---------------------------------------------------------------------------
86
+ /**
87
+ * Returns messages that have not yet been marked as read by `agentName`,
88
+ * including both direct messages and broadcasts addressed to them.
89
+ */
90
+ getUnread(agentName) {
91
+ const read = this.readState.get(agentName) ?? new Set();
92
+ return this.messages.filter((m) => isAddressedTo(m, agentName) && !read.has(m.id));
93
+ }
94
+ /**
95
+ * Returns every message (read or unread) addressed to `agentName`,
96
+ * preserving insertion order.
97
+ */
98
+ getAll(agentName) {
99
+ return this.messages.filter((m) => isAddressedTo(m, agentName));
100
+ }
101
+ /**
102
+ * Mark a set of messages as read for `agentName`.
103
+ * Passing IDs that were already marked, or do not exist, is a no-op.
104
+ */
105
+ markRead(agentName, messageIds) {
106
+ if (messageIds.length === 0)
107
+ return;
108
+ let read = this.readState.get(agentName);
109
+ if (!read) {
110
+ read = new Set();
111
+ this.readState.set(agentName, read);
112
+ }
113
+ for (const id of messageIds) {
114
+ read.add(id);
115
+ }
116
+ }
117
+ /**
118
+ * Returns all messages exchanged between `agent1` and `agent2` (in either
119
+ * direction), sorted chronologically.
120
+ */
121
+ getConversation(agent1, agent2) {
122
+ return this.messages.filter((m) => (m.from === agent1 && m.to === agent2) ||
123
+ (m.from === agent2 && m.to === agent1));
124
+ }
125
+ // ---------------------------------------------------------------------------
126
+ // Subscriptions
127
+ // ---------------------------------------------------------------------------
128
+ /**
129
+ * Subscribe to new messages addressed to `agentName`.
130
+ *
131
+ * The `callback` is invoked synchronously after each matching message is
132
+ * persisted. Returns an unsubscribe function; calling it is idempotent.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const off = bus.subscribe('agent-b', (msg) => handleMessage(msg))
137
+ * // Later…
138
+ * off()
139
+ * ```
140
+ */
141
+ subscribe(agentName, callback) {
142
+ let agentSubs = this.subscribers.get(agentName);
143
+ if (!agentSubs) {
144
+ agentSubs = new Map();
145
+ this.subscribers.set(agentName, agentSubs);
146
+ }
147
+ const id = Symbol();
148
+ agentSubs.set(id, callback);
149
+ return () => {
150
+ agentSubs.delete(id);
151
+ };
152
+ }
153
+ // ---------------------------------------------------------------------------
154
+ // Private helpers
155
+ // ---------------------------------------------------------------------------
156
+ persist(message) {
157
+ this.messages.push(message);
158
+ this.notifySubscribers(message);
159
+ }
160
+ notifySubscribers(message) {
161
+ // Notify direct subscribers of `message.to` (unless broadcast).
162
+ if (message.to !== '*') {
163
+ this.fireCallbacks(message.to, message);
164
+ return;
165
+ }
166
+ // Broadcast: notify all subscribers except the sender.
167
+ for (const [agentName, subs] of this.subscribers) {
168
+ if (agentName !== message.from && subs.size > 0) {
169
+ this.fireCallbacks(agentName, message);
170
+ }
171
+ }
172
+ }
173
+ fireCallbacks(agentName, message) {
174
+ const subs = this.subscribers.get(agentName);
175
+ if (!subs)
176
+ return;
177
+ for (const callback of subs.values()) {
178
+ callback(message);
179
+ }
180
+ }
181
+ }
182
+ //# sourceMappingURL=messaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/team/messaging.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,+DAA+D;AAC/D,SAAS,aAAa,CAAC,OAAgB,EAAE,SAAiB;IACxD,IAAI,OAAO,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC;QACvB,0DAA0D;QAC1D,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,CAAA;IACnC,CAAC;IACD,OAAO,OAAO,CAAC,EAAE,KAAK,SAAS,CAAA;AACjC,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;GAoBG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OAAO,GAAG,EAAE;YACV,SAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACvB,CAAC,CAAA;IACH,CAAC;IAED,8EAA8E;IAC9E,kBAAkB;IAClB,8EAA8E;IAEtE,OAAO,CAAC,OAAgB;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3B,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACjC,CAAC;IAEO,iBAAiB,CAAC,OAAgB;QACxC,gEAAgE;QAChE,IAAI,OAAO,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;YACvC,OAAM;QACR,CAAC;QAED,uDAAuD;QACvD,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACjD,IAAI,SAAS,KAAK,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,SAAiB,EAAE,OAAgB;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC5C,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACrC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @fileoverview Team — the central coordination object for a named group of agents.
3
+ *
4
+ * A {@link Team} owns the agent roster, the inter-agent {@link MessageBus},
5
+ * the {@link TaskQueue}, and (optionally) a {@link SharedMemory} instance.
6
+ * It also exposes a typed event bus so orchestrators can react to lifecycle
7
+ * events without polling.
8
+ */
9
+ import type { AgentConfig, MemoryStore, Task, TeamConfig } from '../types.js';
10
+ import { SharedMemory } from '../memory/shared.js';
11
+ import type { Message } from './messaging.js';
12
+ export type { Message };
13
+ /**
14
+ * Coordinates a named group of agents with shared messaging, task queuing,
15
+ * and optional shared memory.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const team = new Team({
20
+ * name: 'research-team',
21
+ * agents: [researcherConfig, writerConfig],
22
+ * sharedMemory: true,
23
+ * maxConcurrency: 2,
24
+ * })
25
+ *
26
+ * team.on('task:complete', (data) => {
27
+ * const event = data as OrchestratorEvent
28
+ * console.log(`Task done: ${event.task}`)
29
+ * })
30
+ *
31
+ * const task = team.addTask({
32
+ * title: 'Research topic',
33
+ * description: 'Gather background on quantum computing',
34
+ * status: 'pending',
35
+ * assignee: 'researcher',
36
+ * })
37
+ * ```
38
+ */
39
+ export declare class Team {
40
+ readonly name: string;
41
+ readonly config: TeamConfig;
42
+ private readonly agentMap;
43
+ private readonly bus;
44
+ private readonly queue;
45
+ private readonly memory;
46
+ private readonly events;
47
+ constructor(config: TeamConfig);
48
+ /** Returns a shallow copy of the agent configs in registration order. */
49
+ getAgents(): AgentConfig[];
50
+ /**
51
+ * Looks up an agent by name.
52
+ *
53
+ * @returns The {@link AgentConfig} or `undefined` when the name is not known.
54
+ */
55
+ getAgent(name: string): AgentConfig | undefined;
56
+ /**
57
+ * Sends a point-to-point message from `from` to `to`.
58
+ *
59
+ * The message is persisted on the bus and any active subscribers for `to`
60
+ * are notified synchronously.
61
+ */
62
+ sendMessage(from: string, to: string, content: string): void;
63
+ /**
64
+ * Returns all messages (read or unread) addressed to `agentName`, in
65
+ * chronological order.
66
+ */
67
+ getMessages(agentName: string): Message[];
68
+ /**
69
+ * Broadcasts `content` from `from` to every other agent.
70
+ *
71
+ * The `to` field of the resulting message is `'*'`.
72
+ */
73
+ broadcast(from: string, content: string): void;
74
+ /**
75
+ * Creates a new task, adds it to the queue, and returns the persisted
76
+ * {@link Task} (with generated `id`, `createdAt`, and `updatedAt`).
77
+ *
78
+ * @param task - Everything except the generated fields.
79
+ */
80
+ addTask(task: Omit<Task, 'id' | 'createdAt' | 'updatedAt'>): Task;
81
+ /** Returns a snapshot of all tasks in the queue (any status). */
82
+ getTasks(): Task[];
83
+ /** Returns all tasks whose `assignee` is `agentName`. */
84
+ getTasksByAssignee(agentName: string): Task[];
85
+ /**
86
+ * Applies a partial update to the task identified by `taskId`.
87
+ *
88
+ * @throws {Error} when the task is not found.
89
+ */
90
+ updateTask(taskId: string, update: Partial<Task>): Task;
91
+ /**
92
+ * Returns the next `'pending'` task for `agentName`, respecting dependencies.
93
+ *
94
+ * Tries to find a task explicitly assigned to the agent first; falls back to
95
+ * the first unassigned pending task.
96
+ *
97
+ * @returns `undefined` when no ready task exists for this agent.
98
+ */
99
+ getNextTask(agentName: string): Task | undefined;
100
+ /**
101
+ * Returns the shared {@link MemoryStore} for this team, or `undefined` if
102
+ * `sharedMemory` was not enabled in {@link TeamConfig}.
103
+ *
104
+ * Note: the returned value satisfies the {@link MemoryStore} interface.
105
+ * Callers that need the full {@link SharedMemory} API can use the
106
+ * `as SharedMemory` cast, but depending on the concrete type is discouraged.
107
+ */
108
+ getSharedMemory(): MemoryStore | undefined;
109
+ /**
110
+ * Returns the raw {@link SharedMemory} instance (team-internal accessor).
111
+ * Use this when you need the namespacing / `getSummary` features.
112
+ *
113
+ * @internal
114
+ */
115
+ getSharedMemoryInstance(): SharedMemory | undefined;
116
+ /**
117
+ * Subscribes to a team event.
118
+ *
119
+ * Built-in events:
120
+ * - `'task:ready'` — emitted when a task becomes runnable.
121
+ * - `'task:complete'` — emitted when a task completes successfully.
122
+ * - `'task:failed'` — emitted when a task fails.
123
+ * - `'all:complete'` — emitted when every task in the queue has terminated.
124
+ * - `'message'` — emitted on point-to-point messages.
125
+ * - `'broadcast'` — emitted on broadcast messages.
126
+ *
127
+ * `data` is typed as `unknown`; cast to {@link OrchestratorEvent} for
128
+ * structured access.
129
+ *
130
+ * @returns An unsubscribe function.
131
+ */
132
+ on(event: string, handler: (data: unknown) => void): () => void;
133
+ /**
134
+ * Emits a custom event on the team's event bus.
135
+ *
136
+ * Orchestrators can use this to signal domain-specific lifecycle milestones
137
+ * (e.g. `'phase:research:complete'`) without modifying the Team class.
138
+ */
139
+ emit(event: string, data: unknown): void;
140
+ }
141
+ //# sourceMappingURL=team.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.d.ts","sourceRoot":"","sources":["../../src/team/team.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,IAAI,EAEJ,UAAU,EACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAI7C,YAAY,EAAE,OAAO,EAAE,CAAA;AAsCvB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,IAAI;IACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAE3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,MAAM,EAAE,UAAU;IAgD9B,yEAAyE;IACzE,SAAS,IAAI,WAAW,EAAE;IAI1B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAQ/C;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MA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