@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,124 @@
1
+ /**
2
+ * @fileoverview In-memory implementation of {@link MemoryStore}.
3
+ *
4
+ * All data lives in a plain `Map` and is never persisted to disk. This is the
5
+ * default store used by {@link SharedMemory} and is suitable for testing and
6
+ * single-process use-cases. Swap it for a Redis or SQLite-backed implementation
7
+ * in production by satisfying the same {@link MemoryStore} interface.
8
+ */
9
+
10
+ import type { MemoryEntry, MemoryStore } from '../types.js'
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // InMemoryStore
14
+ // ---------------------------------------------------------------------------
15
+
16
+ /**
17
+ * Synchronous-under-the-hood key/value store that exposes an `async` surface
18
+ * so implementations can be swapped for async-native backends without changing
19
+ * callers.
20
+ *
21
+ * All keys are treated as opaque strings. Values are always strings; structured
22
+ * data must be serialised by the caller (e.g. `JSON.stringify`).
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const store = new InMemoryStore()
27
+ * await store.set('config', JSON.stringify({ model: 'claude-opus-4-6' }))
28
+ * const entry = await store.get('config')
29
+ * ```
30
+ */
31
+ export class InMemoryStore implements MemoryStore {
32
+ private readonly data = new Map<string, MemoryEntry>()
33
+
34
+ // ---------------------------------------------------------------------------
35
+ // MemoryStore interface
36
+ // ---------------------------------------------------------------------------
37
+
38
+ /** Returns the entry for `key`, or `null` if not present. */
39
+ async get(key: string): Promise<MemoryEntry | null> {
40
+ return this.data.get(key) ?? null
41
+ }
42
+
43
+ /**
44
+ * Upserts `key` with `value` and optional `metadata`.
45
+ *
46
+ * If the key already exists its `createdAt` is **preserved** so callers can
47
+ * detect when a value was first written.
48
+ */
49
+ async set(
50
+ key: string,
51
+ value: string,
52
+ metadata?: Record<string, unknown>,
53
+ ): Promise<void> {
54
+ const existing = this.data.get(key)
55
+ const entry: MemoryEntry = {
56
+ key,
57
+ value,
58
+ metadata: metadata !== undefined ? { ...metadata } : undefined,
59
+ createdAt: existing?.createdAt ?? new Date(),
60
+ }
61
+ this.data.set(key, entry)
62
+ }
63
+
64
+ /** Returns a snapshot of all entries in insertion order. */
65
+ async list(): Promise<MemoryEntry[]> {
66
+ return Array.from(this.data.values())
67
+ }
68
+
69
+ /**
70
+ * Removes the entry for `key`.
71
+ * Deleting a non-existent key is a no-op.
72
+ */
73
+ async delete(key: string): Promise<void> {
74
+ this.data.delete(key)
75
+ }
76
+
77
+ /** Removes **all** entries from the store. */
78
+ async clear(): Promise<void> {
79
+ this.data.clear()
80
+ }
81
+
82
+ // ---------------------------------------------------------------------------
83
+ // Extensions beyond the base MemoryStore interface
84
+ // ---------------------------------------------------------------------------
85
+
86
+ /**
87
+ * Returns entries whose `key` starts with `query` **or** whose `value`
88
+ * contains `query` (case-insensitive substring match).
89
+ *
90
+ * This is a simple linear scan; it is not suitable for very large stores
91
+ * without an index layer on top.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * // Find all entries related to "research"
96
+ * const hits = await store.search('research')
97
+ * ```
98
+ */
99
+ async search(query: string): Promise<MemoryEntry[]> {
100
+ if (query.length === 0) {
101
+ return this.list()
102
+ }
103
+ const lower = query.toLowerCase()
104
+ return Array.from(this.data.values()).filter(
105
+ (entry) =>
106
+ entry.key.toLowerCase().includes(lower) ||
107
+ entry.value.toLowerCase().includes(lower),
108
+ )
109
+ }
110
+
111
+ // ---------------------------------------------------------------------------
112
+ // Convenience helpers (not part of MemoryStore)
113
+ // ---------------------------------------------------------------------------
114
+
115
+ /** Returns the number of entries currently held in the store. */
116
+ get size(): number {
117
+ return this.data.size
118
+ }
119
+
120
+ /** Returns `true` if `key` exists in the store. */
121
+ has(key: string): boolean {
122
+ return this.data.has(key)
123
+ }
124
+ }