@jackchen_me/open-multi-agent 0.2.0 → 1.0.1

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 (117) hide show
  1. package/README.md +87 -20
  2. package/dist/agent/agent.d.ts +15 -1
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/agent.js +144 -10
  5. package/dist/agent/agent.js.map +1 -1
  6. package/dist/agent/loop-detector.d.ts +39 -0
  7. package/dist/agent/loop-detector.d.ts.map +1 -0
  8. package/dist/agent/loop-detector.js +122 -0
  9. package/dist/agent/loop-detector.js.map +1 -0
  10. package/dist/agent/pool.d.ts +2 -1
  11. package/dist/agent/pool.d.ts.map +1 -1
  12. package/dist/agent/pool.js +4 -2
  13. package/dist/agent/pool.js.map +1 -1
  14. package/dist/agent/runner.d.ts +23 -1
  15. package/dist/agent/runner.d.ts.map +1 -1
  16. package/dist/agent/runner.js +113 -12
  17. package/dist/agent/runner.js.map +1 -1
  18. package/dist/index.d.ts +3 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/llm/adapter.d.ts +4 -1
  23. package/dist/llm/adapter.d.ts.map +1 -1
  24. package/dist/llm/adapter.js +11 -0
  25. package/dist/llm/adapter.js.map +1 -1
  26. package/dist/llm/copilot.d.ts.map +1 -1
  27. package/dist/llm/copilot.js +2 -1
  28. package/dist/llm/copilot.js.map +1 -1
  29. package/dist/llm/gemini.d.ts +65 -0
  30. package/dist/llm/gemini.d.ts.map +1 -0
  31. package/dist/llm/gemini.js +317 -0
  32. package/dist/llm/gemini.js.map +1 -0
  33. package/dist/llm/grok.d.ts +21 -0
  34. package/dist/llm/grok.d.ts.map +1 -0
  35. package/dist/llm/grok.js +24 -0
  36. package/dist/llm/grok.js.map +1 -0
  37. package/dist/llm/openai-common.d.ts +8 -1
  38. package/dist/llm/openai-common.d.ts.map +1 -1
  39. package/dist/llm/openai-common.js +35 -2
  40. package/dist/llm/openai-common.js.map +1 -1
  41. package/dist/llm/openai.d.ts +1 -1
  42. package/dist/llm/openai.d.ts.map +1 -1
  43. package/dist/llm/openai.js +20 -2
  44. package/dist/llm/openai.js.map +1 -1
  45. package/dist/orchestrator/orchestrator.d.ts.map +1 -1
  46. package/dist/orchestrator/orchestrator.js +89 -9
  47. package/dist/orchestrator/orchestrator.js.map +1 -1
  48. package/dist/task/queue.d.ts +31 -2
  49. package/dist/task/queue.d.ts.map +1 -1
  50. package/dist/task/queue.js +69 -2
  51. package/dist/task/queue.js.map +1 -1
  52. package/dist/tool/text-tool-extractor.d.ts +32 -0
  53. package/dist/tool/text-tool-extractor.d.ts.map +1 -0
  54. package/dist/tool/text-tool-extractor.js +187 -0
  55. package/dist/tool/text-tool-extractor.js.map +1 -0
  56. package/dist/types.d.ts +139 -7
  57. package/dist/types.d.ts.map +1 -1
  58. package/dist/utils/trace.d.ts +12 -0
  59. package/dist/utils/trace.d.ts.map +1 -0
  60. package/dist/utils/trace.js +30 -0
  61. package/dist/utils/trace.js.map +1 -0
  62. package/package.json +18 -2
  63. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
  64. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
  65. package/.github/pull_request_template.md +0 -14
  66. package/.github/workflows/ci.yml +0 -23
  67. package/CLAUDE.md +0 -72
  68. package/CODE_OF_CONDUCT.md +0 -48
  69. package/CONTRIBUTING.md +0 -72
  70. package/DECISIONS.md +0 -43
  71. package/README_zh.md +0 -217
  72. package/SECURITY.md +0 -17
  73. package/examples/01-single-agent.ts +0 -131
  74. package/examples/02-team-collaboration.ts +0 -167
  75. package/examples/03-task-pipeline.ts +0 -201
  76. package/examples/04-multi-model-team.ts +0 -261
  77. package/examples/05-copilot-test.ts +0 -49
  78. package/examples/06-local-model.ts +0 -199
  79. package/examples/07-fan-out-aggregate.ts +0 -209
  80. package/examples/08-gemma4-local.ts +0 -203
  81. package/examples/09-gemma4-auto-orchestration.ts +0 -162
  82. package/src/agent/agent.ts +0 -473
  83. package/src/agent/pool.ts +0 -278
  84. package/src/agent/runner.ts +0 -413
  85. package/src/agent/structured-output.ts +0 -126
  86. package/src/index.ts +0 -167
  87. package/src/llm/adapter.ts +0 -87
  88. package/src/llm/anthropic.ts +0 -389
  89. package/src/llm/copilot.ts +0 -551
  90. package/src/llm/openai-common.ts +0 -255
  91. package/src/llm/openai.ts +0 -272
  92. package/src/memory/shared.ts +0 -181
  93. package/src/memory/store.ts +0 -124
  94. package/src/orchestrator/orchestrator.ts +0 -977
  95. package/src/orchestrator/scheduler.ts +0 -352
  96. package/src/task/queue.ts +0 -394
  97. package/src/task/task.ts +0 -239
  98. package/src/team/messaging.ts +0 -232
  99. package/src/team/team.ts +0 -334
  100. package/src/tool/built-in/bash.ts +0 -187
  101. package/src/tool/built-in/file-edit.ts +0 -154
  102. package/src/tool/built-in/file-read.ts +0 -105
  103. package/src/tool/built-in/file-write.ts +0 -81
  104. package/src/tool/built-in/grep.ts +0 -362
  105. package/src/tool/built-in/index.ts +0 -50
  106. package/src/tool/executor.ts +0 -178
  107. package/src/tool/framework.ts +0 -557
  108. package/src/types.ts +0 -391
  109. package/src/utils/semaphore.ts +0 -89
  110. package/tests/semaphore.test.ts +0 -57
  111. package/tests/shared-memory.test.ts +0 -122
  112. package/tests/structured-output.test.ts +0 -331
  113. package/tests/task-queue.test.ts +0 -244
  114. package/tests/task-retry.test.ts +0 -368
  115. package/tests/task-utils.test.ts +0 -155
  116. package/tests/tool-executor.test.ts +0 -193
  117. package/tsconfig.json +0 -25
@@ -1,193 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest'
2
- import { z } from 'zod'
3
- import { ToolRegistry, defineTool } from '../src/tool/framework.js'
4
- import { ToolExecutor } from '../src/tool/executor.js'
5
- import type { ToolUseContext } from '../src/types.js'
6
-
7
- // ---------------------------------------------------------------------------
8
- // Helpers
9
- // ---------------------------------------------------------------------------
10
-
11
- const dummyContext: ToolUseContext = {
12
- agent: { name: 'test-agent', role: 'tester', model: 'test-model' },
13
- }
14
-
15
- function echoTool() {
16
- return defineTool({
17
- name: 'echo',
18
- description: 'Echoes the message.',
19
- inputSchema: z.object({ message: z.string() }),
20
- execute: async ({ message }) => ({ data: message, isError: false }),
21
- })
22
- }
23
-
24
- function failTool() {
25
- return defineTool({
26
- name: 'fail',
27
- description: 'Always throws.',
28
- inputSchema: z.object({}),
29
- execute: async () => {
30
- throw new Error('intentional failure')
31
- },
32
- })
33
- }
34
-
35
- function makeExecutor(...tools: ReturnType<typeof defineTool>[]) {
36
- const registry = new ToolRegistry()
37
- for (const t of tools) registry.register(t)
38
- return { executor: new ToolExecutor(registry), registry }
39
- }
40
-
41
- // ---------------------------------------------------------------------------
42
- // Tests
43
- // ---------------------------------------------------------------------------
44
-
45
- describe('ToolExecutor', () => {
46
- // -------------------------------------------------------------------------
47
- // Single execution
48
- // -------------------------------------------------------------------------
49
-
50
- it('executes a tool and returns its result', async () => {
51
- const { executor } = makeExecutor(echoTool())
52
- const result = await executor.execute('echo', { message: 'hello' }, dummyContext)
53
- expect(result.data).toBe('hello')
54
- expect(result.isError).toBeFalsy()
55
- })
56
-
57
- it('returns an error result for an unknown tool', async () => {
58
- const { executor } = makeExecutor()
59
- const result = await executor.execute('ghost', {}, dummyContext)
60
- expect(result.isError).toBe(true)
61
- expect(result.data).toContain('not registered')
62
- })
63
-
64
- it('returns an error result when Zod validation fails', async () => {
65
- const { executor } = makeExecutor(echoTool())
66
- // 'message' is required but missing
67
- const result = await executor.execute('echo', {}, dummyContext)
68
- expect(result.isError).toBe(true)
69
- expect(result.data).toContain('Invalid input')
70
- })
71
-
72
- it('catches tool execution errors and returns them as error results', async () => {
73
- const { executor } = makeExecutor(failTool())
74
- const result = await executor.execute('fail', {}, dummyContext)
75
- expect(result.isError).toBe(true)
76
- expect(result.data).toContain('intentional failure')
77
- })
78
-
79
- it('returns an error result when aborted before execution', async () => {
80
- const { executor } = makeExecutor(echoTool())
81
- const controller = new AbortController()
82
- controller.abort()
83
-
84
- const result = await executor.execute(
85
- 'echo',
86
- { message: 'hi' },
87
- { ...dummyContext, abortSignal: controller.signal },
88
- )
89
- expect(result.isError).toBe(true)
90
- expect(result.data).toContain('aborted')
91
- })
92
-
93
- // -------------------------------------------------------------------------
94
- // Batch execution
95
- // -------------------------------------------------------------------------
96
-
97
- it('executeBatch runs multiple tools and returns a map of results', async () => {
98
- const { executor } = makeExecutor(echoTool())
99
- const results = await executor.executeBatch(
100
- [
101
- { id: 'c1', name: 'echo', input: { message: 'a' } },
102
- { id: 'c2', name: 'echo', input: { message: 'b' } },
103
- ],
104
- dummyContext,
105
- )
106
-
107
- expect(results.size).toBe(2)
108
- expect(results.get('c1')!.data).toBe('a')
109
- expect(results.get('c2')!.data).toBe('b')
110
- })
111
-
112
- it('executeBatch isolates errors — one failure does not affect others', async () => {
113
- const { executor } = makeExecutor(echoTool(), failTool())
114
- const results = await executor.executeBatch(
115
- [
116
- { id: 'ok', name: 'echo', input: { message: 'fine' } },
117
- { id: 'bad', name: 'fail', input: {} },
118
- ],
119
- dummyContext,
120
- )
121
-
122
- expect(results.get('ok')!.isError).toBeFalsy()
123
- expect(results.get('bad')!.isError).toBe(true)
124
- })
125
-
126
- // -------------------------------------------------------------------------
127
- // Concurrency control
128
- // -------------------------------------------------------------------------
129
-
130
- it('respects maxConcurrency limit', async () => {
131
- let peak = 0
132
- let running = 0
133
-
134
- const trackTool = defineTool({
135
- name: 'track',
136
- description: 'Tracks concurrency.',
137
- inputSchema: z.object({}),
138
- execute: async () => {
139
- running++
140
- peak = Math.max(peak, running)
141
- await new Promise((r) => setTimeout(r, 50))
142
- running--
143
- return { data: 'ok', isError: false }
144
- },
145
- })
146
-
147
- const registry = new ToolRegistry()
148
- registry.register(trackTool)
149
- const executor = new ToolExecutor(registry, { maxConcurrency: 2 })
150
-
151
- await executor.executeBatch(
152
- Array.from({ length: 5 }, (_, i) => ({ id: `t${i}`, name: 'track', input: {} })),
153
- dummyContext,
154
- )
155
-
156
- expect(peak).toBeLessThanOrEqual(2)
157
- })
158
- })
159
-
160
- // ---------------------------------------------------------------------------
161
- // ToolRegistry
162
- // ---------------------------------------------------------------------------
163
-
164
- describe('ToolRegistry', () => {
165
- it('registers and retrieves a tool', () => {
166
- const registry = new ToolRegistry()
167
- registry.register(echoTool())
168
- expect(registry.get('echo')).toBeDefined()
169
- expect(registry.has('echo')).toBe(true)
170
- })
171
-
172
- it('throws on duplicate registration', () => {
173
- const registry = new ToolRegistry()
174
- registry.register(echoTool())
175
- expect(() => registry.register(echoTool())).toThrow('already registered')
176
- })
177
-
178
- it('unregister removes the tool', () => {
179
- const registry = new ToolRegistry()
180
- registry.register(echoTool())
181
- registry.unregister('echo')
182
- expect(registry.has('echo')).toBe(false)
183
- })
184
-
185
- it('toToolDefs produces JSON schema representations', () => {
186
- const registry = new ToolRegistry()
187
- registry.register(echoTool())
188
- const defs = registry.toToolDefs()
189
- expect(defs).toHaveLength(1)
190
- expect(defs[0].name).toBe('echo')
191
- expect(defs[0].inputSchema).toHaveProperty('properties')
192
- })
193
- })
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022"],
7
- "outDir": "dist",
8
- "rootDir": "src",
9
- "declaration": true,
10
- "declarationMap": true,
11
- "sourceMap": true,
12
- "strict": true,
13
- "esModuleInterop": true,
14
- "skipLibCheck": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "resolveJsonModule": true,
17
- "isolatedModules": true,
18
- "noUnusedLocals": false,
19
- "noUnusedParameters": false,
20
- "noImplicitReturns": true,
21
- "noFallthroughCasesInSwitch": true
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist", "examples", "tests"]
25
- }