@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.
- package/LICENSE +21 -0
- package/README.md +280 -0
- package/dist/agent/agent.d.ts +121 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +294 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/pool.d.ts +128 -0
- package/dist/agent/pool.d.ts.map +1 -0
- package/dist/agent/pool.js +236 -0
- package/dist/agent/pool.js.map +1 -0
- package/dist/agent/runner.d.ts +120 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +274 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/adapter.d.ts +38 -0
- package/dist/llm/adapter.d.ts.map +1 -0
- package/dist/llm/adapter.js +46 -0
- package/dist/llm/adapter.js.map +1 -0
- package/dist/llm/anthropic.d.ts +56 -0
- package/dist/llm/anthropic.d.ts.map +1 -0
- package/dist/llm/anthropic.js +307 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/openai.d.ts +62 -0
- package/dist/llm/openai.d.ts.map +1 -0
- package/dist/llm/openai.js +424 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/memory/shared.d.ts +86 -0
- package/dist/memory/shared.d.ts.map +1 -0
- package/dist/memory/shared.js +155 -0
- package/dist/memory/shared.js.map +1 -0
- package/dist/memory/store.d.ts +64 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +103 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +173 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.js +698 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/orchestrator/scheduler.d.ts +112 -0
- package/dist/orchestrator/scheduler.d.ts.map +1 -0
- package/dist/orchestrator/scheduler.js +282 -0
- package/dist/orchestrator/scheduler.js.map +1 -0
- package/dist/task/queue.d.ts +160 -0
- package/dist/task/queue.d.ts.map +1 -0
- package/dist/task/queue.js +337 -0
- package/dist/task/queue.js.map +1 -0
- package/dist/task/task.d.ts +86 -0
- package/dist/task/task.d.ts.map +1 -0
- package/dist/task/task.js +201 -0
- package/dist/task/task.js.map +1 -0
- package/dist/team/messaging.d.ts +106 -0
- package/dist/team/messaging.d.ts.map +1 -0
- package/dist/team/messaging.js +182 -0
- package/dist/team/messaging.js.map +1 -0
- package/dist/team/team.d.ts +141 -0
- package/dist/team/team.d.ts.map +1 -0
- package/dist/team/team.js +282 -0
- package/dist/team/team.js.map +1 -0
- package/dist/tool/built-in/bash.d.ts +12 -0
- package/dist/tool/built-in/bash.d.ts.map +1 -0
- package/dist/tool/built-in/bash.js +133 -0
- package/dist/tool/built-in/bash.js.map +1 -0
- package/dist/tool/built-in/file-edit.d.ts +14 -0
- package/dist/tool/built-in/file-edit.d.ts.map +1 -0
- package/dist/tool/built-in/file-edit.js +130 -0
- package/dist/tool/built-in/file-edit.js.map +1 -0
- package/dist/tool/built-in/file-read.d.ts +12 -0
- package/dist/tool/built-in/file-read.d.ts.map +1 -0
- package/dist/tool/built-in/file-read.js +82 -0
- package/dist/tool/built-in/file-read.js.map +1 -0
- package/dist/tool/built-in/file-write.d.ts +11 -0
- package/dist/tool/built-in/file-write.d.ts.map +1 -0
- package/dist/tool/built-in/file-write.js +70 -0
- package/dist/tool/built-in/file-write.js.map +1 -0
- package/dist/tool/built-in/grep.d.ts +15 -0
- package/dist/tool/built-in/grep.d.ts.map +1 -0
- package/dist/tool/built-in/grep.js +287 -0
- package/dist/tool/built-in/grep.js.map +1 -0
- package/dist/tool/built-in/index.d.ts +36 -0
- package/dist/tool/built-in/index.d.ts.map +1 -0
- package/dist/tool/built-in/index.js +45 -0
- package/dist/tool/built-in/index.js.map +1 -0
- package/dist/tool/executor.d.ts +71 -0
- package/dist/tool/executor.d.ts.map +1 -0
- package/dist/tool/executor.js +116 -0
- package/dist/tool/executor.js.map +1 -0
- package/dist/tool/framework.d.ts +143 -0
- package/dist/tool/framework.d.ts.map +1 -0
- package/dist/tool/framework.js +371 -0
- package/dist/tool/framework.js.map +1 -0
- package/dist/types.d.ts +285 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/semaphore.d.ts +47 -0
- package/dist/utils/semaphore.d.ts.map +1 -0
- package/dist/utils/semaphore.js +85 -0
- package/dist/utils/semaphore.js.map +1 -0
- package/examples/01-single-agent.ts +131 -0
- package/examples/02-team-collaboration.ts +167 -0
- package/examples/03-task-pipeline.ts +201 -0
- package/examples/04-multi-model-team.ts +261 -0
- package/package.json +49 -0
- package/src/agent/agent.ts +364 -0
- package/src/agent/pool.ts +278 -0
- package/src/agent/runner.ts +413 -0
- package/src/index.ts +166 -0
- package/src/llm/adapter.ts +74 -0
- package/src/llm/anthropic.ts +388 -0
- package/src/llm/openai.ts +522 -0
- package/src/memory/shared.ts +181 -0
- package/src/memory/store.ts +124 -0
- package/src/orchestrator/orchestrator.ts +851 -0
- package/src/orchestrator/scheduler.ts +352 -0
- package/src/task/queue.ts +394 -0
- package/src/task/task.ts +232 -0
- package/src/team/messaging.ts +230 -0
- package/src/team/team.ts +334 -0
- package/src/tool/built-in/bash.ts +187 -0
- package/src/tool/built-in/file-edit.ts +154 -0
- package/src/tool/built-in/file-read.ts +105 -0
- package/src/tool/built-in/file-write.ts +81 -0
- package/src/tool/built-in/grep.ts +362 -0
- package/src/tool/built-in/index.ts +50 -0
- package/src/tool/executor.ts +178 -0
- package/src/tool/framework.ts +557 -0
- package/src/types.ts +362 -0
- package/src/utils/semaphore.ts +89 -0
- 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
|
+
}
|