@jackchen_me/open-multi-agent 0.1.0 → 1.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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- package/.github/pull_request_template.md +14 -0
- package/.github/workflows/ci.yml +23 -0
- package/CLAUDE.md +80 -0
- package/CODE_OF_CONDUCT.md +48 -0
- package/CONTRIBUTING.md +72 -0
- package/DECISIONS.md +43 -0
- package/README.md +144 -144
- package/README_zh.md +277 -0
- package/SECURITY.md +17 -0
- package/dist/agent/agent.d.ts +20 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +233 -12
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/loop-detector.d.ts +39 -0
- package/dist/agent/loop-detector.d.ts.map +1 -0
- package/dist/agent/loop-detector.js +122 -0
- package/dist/agent/loop-detector.js.map +1 -0
- package/dist/agent/pool.d.ts +2 -1
- package/dist/agent/pool.d.ts.map +1 -1
- package/dist/agent/pool.js +4 -2
- package/dist/agent/pool.js.map +1 -1
- package/dist/agent/runner.d.ts +23 -1
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +113 -12
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/structured-output.d.ts +33 -0
- package/dist/agent/structured-output.d.ts.map +1 -0
- package/dist/agent/structured-output.js +116 -0
- package/dist/agent/structured-output.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/adapter.d.ts +12 -4
- package/dist/llm/adapter.d.ts.map +1 -1
- package/dist/llm/adapter.js +28 -5
- package/dist/llm/adapter.js.map +1 -1
- package/dist/llm/anthropic.d.ts +1 -1
- package/dist/llm/anthropic.d.ts.map +1 -1
- package/dist/llm/anthropic.js +2 -1
- package/dist/llm/anthropic.js.map +1 -1
- package/dist/llm/copilot.d.ts +92 -0
- package/dist/llm/copilot.d.ts.map +1 -0
- package/dist/llm/copilot.js +427 -0
- package/dist/llm/copilot.js.map +1 -0
- package/dist/llm/gemini.d.ts +65 -0
- package/dist/llm/gemini.d.ts.map +1 -0
- package/dist/llm/gemini.js +317 -0
- package/dist/llm/gemini.js.map +1 -0
- package/dist/llm/grok.d.ts +21 -0
- package/dist/llm/grok.d.ts.map +1 -0
- package/dist/llm/grok.js +24 -0
- package/dist/llm/grok.js.map +1 -0
- package/dist/llm/openai-common.d.ts +54 -0
- package/dist/llm/openai-common.d.ts.map +1 -0
- package/dist/llm/openai-common.js +242 -0
- package/dist/llm/openai-common.js.map +1 -0
- package/dist/llm/openai.d.ts +2 -2
- package/dist/llm/openai.d.ts.map +1 -1
- package/dist/llm/openai.js +23 -226
- package/dist/llm/openai.js.map +1 -1
- package/dist/orchestrator/orchestrator.d.ts +25 -1
- package/dist/orchestrator/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator/orchestrator.js +214 -41
- package/dist/orchestrator/orchestrator.js.map +1 -1
- package/dist/task/queue.d.ts +31 -2
- package/dist/task/queue.d.ts.map +1 -1
- package/dist/task/queue.js +70 -3
- package/dist/task/queue.js.map +1 -1
- package/dist/task/task.d.ts +3 -0
- package/dist/task/task.d.ts.map +1 -1
- package/dist/task/task.js +5 -1
- package/dist/task/task.js.map +1 -1
- package/dist/team/messaging.d.ts.map +1 -1
- package/dist/team/messaging.js +2 -1
- package/dist/team/messaging.js.map +1 -1
- package/dist/tool/text-tool-extractor.d.ts +32 -0
- package/dist/tool/text-tool-extractor.d.ts.map +1 -0
- package/dist/tool/text-tool-extractor.js +187 -0
- package/dist/tool/text-tool-extractor.js.map +1 -0
- package/dist/types.d.ts +167 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/trace.d.ts +12 -0
- package/dist/utils/trace.d.ts.map +1 -0
- package/dist/utils/trace.js +30 -0
- package/dist/utils/trace.js.map +1 -0
- package/examples/05-copilot-test.ts +49 -0
- package/examples/06-local-model.ts +200 -0
- package/examples/07-fan-out-aggregate.ts +209 -0
- package/examples/08-gemma4-local.ts +192 -0
- package/examples/09-structured-output.ts +73 -0
- package/examples/10-task-retry.ts +132 -0
- package/examples/11-trace-observability.ts +133 -0
- package/examples/12-grok.ts +154 -0
- package/examples/13-gemini.ts +48 -0
- package/package.json +14 -3
- package/src/agent/agent.ts +273 -15
- package/src/agent/loop-detector.ts +137 -0
- package/src/agent/pool.ts +9 -2
- package/src/agent/runner.ts +148 -19
- package/src/agent/structured-output.ts +126 -0
- package/src/index.ts +17 -1
- package/src/llm/adapter.ts +29 -5
- package/src/llm/anthropic.ts +2 -1
- package/src/llm/copilot.ts +552 -0
- package/src/llm/gemini.ts +378 -0
- package/src/llm/grok.ts +29 -0
- package/src/llm/openai-common.ts +294 -0
- package/src/llm/openai.ts +31 -261
- package/src/orchestrator/orchestrator.ts +260 -40
- package/src/task/queue.ts +74 -4
- package/src/task/task.ts +8 -1
- package/src/team/messaging.ts +3 -1
- package/src/tool/text-tool-extractor.ts +219 -0
- package/src/types.ts +186 -6
- package/src/utils/trace.ts +34 -0
- package/tests/agent-hooks.test.ts +473 -0
- package/tests/agent-pool.test.ts +212 -0
- package/tests/approval.test.ts +464 -0
- package/tests/built-in-tools.test.ts +393 -0
- package/tests/gemini-adapter.test.ts +97 -0
- package/tests/grok-adapter.test.ts +74 -0
- package/tests/llm-adapters.test.ts +357 -0
- package/tests/loop-detection.test.ts +456 -0
- package/tests/openai-fallback.test.ts +159 -0
- package/tests/orchestrator.test.ts +281 -0
- package/tests/scheduler.test.ts +221 -0
- package/tests/semaphore.test.ts +57 -0
- package/tests/shared-memory.test.ts +122 -0
- package/tests/structured-output.test.ts +331 -0
- package/tests/task-queue.test.ts +244 -0
- package/tests/task-retry.test.ts +368 -0
- package/tests/task-utils.test.ts +155 -0
- package/tests/team-messaging.test.ts +329 -0
- package/tests/text-tool-extractor.test.ts +170 -0
- package/tests/tool-executor.test.ts +193 -0
- package/tests/trace.test.ts +453 -0
- package/vitest.config.ts +9 -0
package/dist/types.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface LLMResponse {
|
|
|
72
72
|
* - `error` — an unrecoverable error occurred; `data` is an `Error`
|
|
73
73
|
*/
|
|
74
74
|
export interface StreamEvent {
|
|
75
|
-
readonly type: 'text' | 'tool_use' | 'tool_result' | 'done' | 'error';
|
|
75
|
+
readonly type: 'text' | 'tool_use' | 'tool_result' | 'loop_detected' | 'done' | 'error';
|
|
76
76
|
readonly data: unknown;
|
|
77
77
|
}
|
|
78
78
|
/** The serialisable tool schema sent to the LLM provider. */
|
|
@@ -145,17 +145,90 @@ export interface ToolDefinition<TInput = Record<string, unknown>> {
|
|
|
145
145
|
readonly inputSchema: ZodSchema<TInput>;
|
|
146
146
|
execute(input: TInput, context: ToolUseContext): Promise<ToolResult>;
|
|
147
147
|
}
|
|
148
|
+
/** Context passed to the {@link AgentConfig.beforeRun} hook. */
|
|
149
|
+
export interface BeforeRunHookContext {
|
|
150
|
+
/** The user prompt text. */
|
|
151
|
+
readonly prompt: string;
|
|
152
|
+
/** The agent's static configuration. */
|
|
153
|
+
readonly agent: AgentConfig;
|
|
154
|
+
}
|
|
148
155
|
/** Static configuration for a single agent. */
|
|
149
156
|
export interface AgentConfig {
|
|
150
157
|
readonly name: string;
|
|
151
158
|
readonly model: string;
|
|
152
|
-
readonly provider?: 'anthropic' | 'openai';
|
|
159
|
+
readonly provider?: 'anthropic' | 'copilot' | 'grok' | 'openai' | 'gemini';
|
|
160
|
+
/**
|
|
161
|
+
* Custom base URL for OpenAI-compatible APIs (Ollama, vLLM, LM Studio, etc.).
|
|
162
|
+
* Note: local servers that don't require auth still need `apiKey` set to a
|
|
163
|
+
* non-empty placeholder (e.g. `'ollama'`) because the OpenAI SDK validates it.
|
|
164
|
+
*/
|
|
165
|
+
readonly baseURL?: string;
|
|
166
|
+
/** API key override; falls back to the provider's standard env var. */
|
|
167
|
+
readonly apiKey?: string;
|
|
153
168
|
readonly systemPrompt?: string;
|
|
154
169
|
/** Names of tools (from the tool registry) available to this agent. */
|
|
155
170
|
readonly tools?: readonly string[];
|
|
156
171
|
readonly maxTurns?: number;
|
|
157
172
|
readonly maxTokens?: number;
|
|
158
173
|
readonly temperature?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Maximum wall-clock time (in milliseconds) for the entire agent run.
|
|
176
|
+
* When exceeded, the run is aborted via `AbortSignal.timeout()`.
|
|
177
|
+
* Useful for local models where inference can be unpredictably slow.
|
|
178
|
+
*/
|
|
179
|
+
readonly timeoutMs?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Loop detection configuration. When set, the agent tracks repeated tool
|
|
182
|
+
* calls and text outputs to detect stuck loops before `maxTurns` is reached.
|
|
183
|
+
*/
|
|
184
|
+
readonly loopDetection?: LoopDetectionConfig;
|
|
185
|
+
/**
|
|
186
|
+
* Optional Zod schema for structured output. When set, the agent's final
|
|
187
|
+
* output is parsed as JSON and validated against this schema. A single
|
|
188
|
+
* retry with error feedback is attempted on validation failure.
|
|
189
|
+
*/
|
|
190
|
+
readonly outputSchema?: ZodSchema;
|
|
191
|
+
/**
|
|
192
|
+
* Called before each agent run. Receives the prompt and agent config.
|
|
193
|
+
* Return a (possibly modified) context to continue, or throw to abort the run.
|
|
194
|
+
* Only `prompt` from the returned context is applied; `agent` is read-only informational.
|
|
195
|
+
*/
|
|
196
|
+
readonly beforeRun?: (context: BeforeRunHookContext) => Promise<BeforeRunHookContext> | BeforeRunHookContext;
|
|
197
|
+
/**
|
|
198
|
+
* Called after each agent run completes successfully. Receives the run result.
|
|
199
|
+
* Return a (possibly modified) result, or throw to mark the run as failed.
|
|
200
|
+
* Not called when the run throws. For error observation, handle errors at the call site.
|
|
201
|
+
*/
|
|
202
|
+
readonly afterRun?: (result: AgentRunResult) => Promise<AgentRunResult> | AgentRunResult;
|
|
203
|
+
}
|
|
204
|
+
/** Configuration for agent loop detection. */
|
|
205
|
+
export interface LoopDetectionConfig {
|
|
206
|
+
/**
|
|
207
|
+
* Maximum consecutive times the same tool call (name + args) or text
|
|
208
|
+
* output can repeat before detection triggers. Default: `3`.
|
|
209
|
+
*/
|
|
210
|
+
readonly maxRepetitions?: number;
|
|
211
|
+
/**
|
|
212
|
+
* Number of recent turns to track for repetition analysis. Default: `4`.
|
|
213
|
+
*/
|
|
214
|
+
readonly loopDetectionWindow?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Action to take when a loop is detected.
|
|
217
|
+
* - `'warn'` — inject a "you appear stuck" message, give the LLM one
|
|
218
|
+
* more chance; terminate if the loop persists (default)
|
|
219
|
+
* - `'terminate'` — stop the run immediately
|
|
220
|
+
* - `function` — custom callback (sync or async); return `'continue'`,
|
|
221
|
+
* `'inject'`, or `'terminate'` to control the outcome
|
|
222
|
+
*/
|
|
223
|
+
readonly onLoopDetected?: 'warn' | 'terminate' | ((info: LoopDetectionInfo) => 'continue' | 'inject' | 'terminate' | Promise<'continue' | 'inject' | 'terminate'>);
|
|
224
|
+
}
|
|
225
|
+
/** Diagnostic payload emitted when a loop is detected. */
|
|
226
|
+
export interface LoopDetectionInfo {
|
|
227
|
+
readonly kind: 'tool_repetition' | 'text_repetition';
|
|
228
|
+
/** Number of consecutive identical occurrences observed. */
|
|
229
|
+
readonly repetitions: number;
|
|
230
|
+
/** Human-readable description of the detected loop. */
|
|
231
|
+
readonly detail: string;
|
|
159
232
|
}
|
|
160
233
|
/** Lifecycle state tracked during an agent run. */
|
|
161
234
|
export interface AgentState {
|
|
@@ -179,6 +252,14 @@ export interface AgentRunResult {
|
|
|
179
252
|
readonly messages: LLMMessage[];
|
|
180
253
|
readonly tokenUsage: TokenUsage;
|
|
181
254
|
readonly toolCalls: ToolCallRecord[];
|
|
255
|
+
/**
|
|
256
|
+
* Parsed and validated structured output when `outputSchema` is set on the
|
|
257
|
+
* agent config. `undefined` when no schema is configured or validation
|
|
258
|
+
* failed after retry.
|
|
259
|
+
*/
|
|
260
|
+
readonly structured?: unknown;
|
|
261
|
+
/** True when the run was terminated or warned due to loop detection. */
|
|
262
|
+
readonly loopDetected?: boolean;
|
|
182
263
|
}
|
|
183
264
|
/** Static configuration for a team of cooperating agents. */
|
|
184
265
|
export interface TeamConfig {
|
|
@@ -195,7 +276,7 @@ export interface TeamRunResult {
|
|
|
195
276
|
readonly totalTokenUsage: TokenUsage;
|
|
196
277
|
}
|
|
197
278
|
/** Valid states for a {@link Task}. */
|
|
198
|
-
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'blocked';
|
|
279
|
+
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'blocked' | 'skipped';
|
|
199
280
|
/** A discrete unit of work tracked by the orchestrator. */
|
|
200
281
|
export interface Task {
|
|
201
282
|
readonly id: string;
|
|
@@ -209,10 +290,21 @@ export interface Task {
|
|
|
209
290
|
result?: string;
|
|
210
291
|
readonly createdAt: Date;
|
|
211
292
|
updatedAt: Date;
|
|
293
|
+
/** Maximum number of retry attempts on failure (default: 0 — no retry). */
|
|
294
|
+
readonly maxRetries?: number;
|
|
295
|
+
/** Base delay in ms before the first retry (default: 1000). */
|
|
296
|
+
readonly retryDelayMs?: number;
|
|
297
|
+
/** Exponential backoff multiplier (default: 2). */
|
|
298
|
+
readonly retryBackoff?: number;
|
|
212
299
|
}
|
|
213
|
-
/**
|
|
300
|
+
/**
|
|
301
|
+
* Progress event emitted by the orchestrator during a run.
|
|
302
|
+
*
|
|
303
|
+
* **v0.3 addition:** `'task_skipped'` — consumers with exhaustive switches
|
|
304
|
+
* on `type` will need to add a case for this variant.
|
|
305
|
+
*/
|
|
214
306
|
export interface OrchestratorEvent {
|
|
215
|
-
readonly type: 'agent_start' | 'agent_complete' | 'task_start' | 'task_complete' | 'message' | 'error';
|
|
307
|
+
readonly type: 'agent_start' | 'agent_complete' | 'task_start' | 'task_complete' | 'task_skipped' | 'task_retry' | 'message' | 'error';
|
|
216
308
|
readonly agent?: string;
|
|
217
309
|
readonly task?: string;
|
|
218
310
|
readonly data?: unknown;
|
|
@@ -221,9 +313,77 @@ export interface OrchestratorEvent {
|
|
|
221
313
|
export interface OrchestratorConfig {
|
|
222
314
|
readonly maxConcurrency?: number;
|
|
223
315
|
readonly defaultModel?: string;
|
|
224
|
-
readonly defaultProvider?: 'anthropic' | 'openai';
|
|
225
|
-
|
|
316
|
+
readonly defaultProvider?: 'anthropic' | 'copilot' | 'grok' | 'openai' | 'gemini';
|
|
317
|
+
readonly defaultBaseURL?: string;
|
|
318
|
+
readonly defaultApiKey?: string;
|
|
319
|
+
readonly onProgress?: (event: OrchestratorEvent) => void;
|
|
320
|
+
readonly onTrace?: (event: TraceEvent) => void | Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Optional approval gate called between task execution rounds.
|
|
323
|
+
*
|
|
324
|
+
* After a batch of tasks completes, this callback receives all
|
|
325
|
+
* completed {@link Task}s from that round and the list of tasks about
|
|
326
|
+
* to start next. Return `true` to continue or `false` to abort —
|
|
327
|
+
* remaining tasks will be marked `'skipped'`.
|
|
328
|
+
*
|
|
329
|
+
* Not called when:
|
|
330
|
+
* - No tasks succeeded in the round (all failed).
|
|
331
|
+
* - No pending tasks remain after the round (final batch).
|
|
332
|
+
*
|
|
333
|
+
* **Note:** Do not mutate the {@link Task} objects passed to this
|
|
334
|
+
* callback — they are live references to queue state. Mutation is
|
|
335
|
+
* undefined behavior.
|
|
336
|
+
*/
|
|
337
|
+
readonly onApproval?: (completedTasks: readonly Task[], nextTasks: readonly Task[]) => Promise<boolean>;
|
|
338
|
+
}
|
|
339
|
+
/** Trace event type discriminants. */
|
|
340
|
+
export type TraceEventType = 'llm_call' | 'tool_call' | 'task' | 'agent';
|
|
341
|
+
/** Shared fields present on every trace event. */
|
|
342
|
+
export interface TraceEventBase {
|
|
343
|
+
/** Unique identifier for the entire run (runTeam / runTasks / runAgent call). */
|
|
344
|
+
readonly runId: string;
|
|
345
|
+
readonly type: TraceEventType;
|
|
346
|
+
/** Unix epoch ms when the span started. */
|
|
347
|
+
readonly startMs: number;
|
|
348
|
+
/** Unix epoch ms when the span ended. */
|
|
349
|
+
readonly endMs: number;
|
|
350
|
+
/** Wall-clock duration in milliseconds (`endMs - startMs`). */
|
|
351
|
+
readonly durationMs: number;
|
|
352
|
+
/** Agent name associated with this span. */
|
|
353
|
+
readonly agent: string;
|
|
354
|
+
/** Task ID associated with this span. */
|
|
355
|
+
readonly taskId?: string;
|
|
356
|
+
}
|
|
357
|
+
/** Emitted for each LLM API call (one per agent turn). */
|
|
358
|
+
export interface LLMCallTrace extends TraceEventBase {
|
|
359
|
+
readonly type: 'llm_call';
|
|
360
|
+
readonly model: string;
|
|
361
|
+
readonly turn: number;
|
|
362
|
+
readonly tokens: TokenUsage;
|
|
363
|
+
}
|
|
364
|
+
/** Emitted for each tool execution. */
|
|
365
|
+
export interface ToolCallTrace extends TraceEventBase {
|
|
366
|
+
readonly type: 'tool_call';
|
|
367
|
+
readonly tool: string;
|
|
368
|
+
readonly isError: boolean;
|
|
369
|
+
}
|
|
370
|
+
/** Emitted when a task completes (wraps the full retry sequence). */
|
|
371
|
+
export interface TaskTrace extends TraceEventBase {
|
|
372
|
+
readonly type: 'task';
|
|
373
|
+
readonly taskId: string;
|
|
374
|
+
readonly taskTitle: string;
|
|
375
|
+
readonly success: boolean;
|
|
376
|
+
readonly retries: number;
|
|
377
|
+
}
|
|
378
|
+
/** Emitted when an agent run completes (wraps the full conversation loop). */
|
|
379
|
+
export interface AgentTrace extends TraceEventBase {
|
|
380
|
+
readonly type: 'agent';
|
|
381
|
+
readonly turns: number;
|
|
382
|
+
readonly tokens: TokenUsage;
|
|
383
|
+
readonly toolCalls: number;
|
|
226
384
|
}
|
|
385
|
+
/** Discriminated union of all trace event types. */
|
|
386
|
+
export type TraceEvent = LLMCallTrace | ToolCallTrace | TaskTrace | AgentTrace;
|
|
227
387
|
/** A single key-value record stored in a {@link MemoryStore}. */
|
|
228
388
|
export interface MemoryEntry {
|
|
229
389
|
readonly key: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CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClF,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;IAC9B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAMD,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAE3E;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;CACtF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Trace emission utilities for the observability layer.
|
|
3
|
+
*/
|
|
4
|
+
import type { TraceEvent } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Safely emit a trace event. Swallows callback errors so a broken
|
|
7
|
+
* subscriber never crashes agent execution.
|
|
8
|
+
*/
|
|
9
|
+
export declare function emitTrace(fn: ((event: TraceEvent) => void | Promise<void>) | undefined, event: TraceEvent): void;
|
|
10
|
+
/** Generate a unique run ID for trace correlation. */
|
|
11
|
+
export declare function generateRunId(): string;
|
|
12
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C;;;GAGG;AACH,wBAAgB,SAAS,CACvB,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,EAC7D,KAAK,EAAE,UAAU,GAChB,IAAI,CAYN;AAID,sDAAsD;AACtD,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Trace emission utilities for the observability layer.
|
|
3
|
+
*/
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
/**
|
|
6
|
+
* Safely emit a trace event. Swallows callback errors so a broken
|
|
7
|
+
* subscriber never crashes agent execution.
|
|
8
|
+
*/
|
|
9
|
+
export function emitTrace(fn, event) {
|
|
10
|
+
if (!fn)
|
|
11
|
+
return;
|
|
12
|
+
try {
|
|
13
|
+
// Guard async callbacks: if fn returns a Promise, swallow its rejection
|
|
14
|
+
// so an async onTrace never produces an unhandled promise rejection.
|
|
15
|
+
const result = fn(event);
|
|
16
|
+
if (result && typeof result.catch === 'function') {
|
|
17
|
+
;
|
|
18
|
+
result.catch(noop);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// Intentionally swallowed — observability must never break execution.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function noop() { }
|
|
26
|
+
/** Generate a unique run ID for trace correlation. */
|
|
27
|
+
export function generateRunId() {
|
|
28
|
+
return randomUUID();
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC;;;GAGG;AACH,MAAM,UAAU,SAAS,CACvB,EAA6D,EAC7D,KAAiB;IAEjB,IAAI,CAAC,EAAE;QAAE,OAAM;IACf,IAAI,CAAC;QACH,wEAAwE;QACxE,qEAAqE;QACrE,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAY,CAAA;QACnC,IAAI,MAAM,IAAI,OAAQ,MAA2B,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YACvE,CAAC;YAAC,MAA2B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sEAAsE;IACxE,CAAC;AACH,CAAC;AAED,SAAS,IAAI,KAAI,CAAC;AAElB,sDAAsD;AACtD,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,EAAE,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quick smoke test for the Copilot adapter.
|
|
3
|
+
*
|
|
4
|
+
* Run:
|
|
5
|
+
* npx tsx examples/05-copilot-test.ts
|
|
6
|
+
*
|
|
7
|
+
* If GITHUB_COPILOT_TOKEN is not set, the adapter will start an interactive
|
|
8
|
+
* OAuth2 device flow — you'll be prompted to sign in via your browser.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { OpenMultiAgent } from '../src/index.js'
|
|
12
|
+
import type { OrchestratorEvent } from '../src/types.js'
|
|
13
|
+
|
|
14
|
+
const orchestrator = new OpenMultiAgent({
|
|
15
|
+
defaultModel: 'gpt-4o',
|
|
16
|
+
defaultProvider: 'copilot',
|
|
17
|
+
onProgress: (event: OrchestratorEvent) => {
|
|
18
|
+
if (event.type === 'agent_start') {
|
|
19
|
+
console.log(`[start] agent=${event.agent}`)
|
|
20
|
+
} else if (event.type === 'agent_complete') {
|
|
21
|
+
console.log(`[complete] agent=${event.agent}`)
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
console.log('Testing Copilot adapter with gpt-4o...\n')
|
|
27
|
+
|
|
28
|
+
const result = await orchestrator.runAgent(
|
|
29
|
+
{
|
|
30
|
+
name: 'assistant',
|
|
31
|
+
model: 'gpt-4o',
|
|
32
|
+
provider: 'copilot',
|
|
33
|
+
systemPrompt: 'You are a helpful assistant. Keep answers brief.',
|
|
34
|
+
maxTurns: 1,
|
|
35
|
+
maxTokens: 256,
|
|
36
|
+
},
|
|
37
|
+
'What is 2 + 2? Reply in one sentence.',
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if (result.success) {
|
|
41
|
+
console.log('\nAgent output:')
|
|
42
|
+
console.log('─'.repeat(60))
|
|
43
|
+
console.log(result.output)
|
|
44
|
+
console.log('─'.repeat(60))
|
|
45
|
+
console.log(`\nTokens: input=${result.tokenUsage.input_tokens}, output=${result.tokenUsage.output_tokens}`)
|
|
46
|
+
} else {
|
|
47
|
+
console.error('Agent failed:', result.output)
|
|
48
|
+
process.exit(1)
|
|
49
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example 06 — Local Model + Cloud Model Team (Ollama + Claude)
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates mixing a local model served by Ollama with a cloud model
|
|
5
|
+
* (Claude) in the same task pipeline. The key technique is using
|
|
6
|
+
* `provider: 'openai'` with a custom `baseURL` pointing at Ollama's
|
|
7
|
+
* OpenAI-compatible endpoint.
|
|
8
|
+
*
|
|
9
|
+
* This pattern works with ANY OpenAI-compatible local server:
|
|
10
|
+
* - Ollama → http://localhost:11434/v1
|
|
11
|
+
* - vLLM → http://localhost:8000/v1
|
|
12
|
+
* - LM Studio → http://localhost:1234/v1
|
|
13
|
+
* - llama.cpp → http://localhost:8080/v1
|
|
14
|
+
* Just change the baseURL and model name below.
|
|
15
|
+
*
|
|
16
|
+
* Run:
|
|
17
|
+
* npx tsx examples/06-local-model.ts
|
|
18
|
+
*
|
|
19
|
+
* Prerequisites:
|
|
20
|
+
* 1. Ollama installed and running: https://ollama.com
|
|
21
|
+
* 2. Pull the model: ollama pull llama3.1
|
|
22
|
+
* 3. ANTHROPIC_API_KEY env var must be set.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { OpenMultiAgent } from '../src/index.js'
|
|
26
|
+
import type { AgentConfig, OrchestratorEvent, Task } from '../src/types.js'
|
|
27
|
+
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Agents
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Coder — uses Claude (Anthropic) for high-quality code generation.
|
|
34
|
+
*/
|
|
35
|
+
const coder: AgentConfig = {
|
|
36
|
+
name: 'coder',
|
|
37
|
+
model: 'claude-sonnet-4-6',
|
|
38
|
+
provider: 'anthropic',
|
|
39
|
+
systemPrompt: `You are a senior TypeScript developer. Write clean, well-typed,
|
|
40
|
+
production-quality code. Use the tools to write files to /tmp/local-model-demo/.
|
|
41
|
+
Always include brief JSDoc comments on exported functions.`,
|
|
42
|
+
tools: ['bash', 'file_write'],
|
|
43
|
+
maxTurns: 6,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Reviewer — uses a local Ollama model via the OpenAI-compatible API.
|
|
48
|
+
* The apiKey is required by the OpenAI SDK but Ollama ignores it,
|
|
49
|
+
* so we pass the placeholder string 'ollama'.
|
|
50
|
+
*/
|
|
51
|
+
const reviewer: AgentConfig = {
|
|
52
|
+
name: 'reviewer',
|
|
53
|
+
model: 'llama3.1',
|
|
54
|
+
provider: 'openai', // 'openai' here means "OpenAI-compatible protocol", not the OpenAI cloud
|
|
55
|
+
baseURL: 'http://localhost:11434/v1',
|
|
56
|
+
apiKey: 'ollama',
|
|
57
|
+
systemPrompt: `You are a code reviewer. You read source files and produce a structured review.
|
|
58
|
+
Your review MUST include these sections:
|
|
59
|
+
- Summary (2-3 sentences)
|
|
60
|
+
- Strengths (bullet list)
|
|
61
|
+
- Issues (bullet list — or "None found" if the code is clean)
|
|
62
|
+
- Verdict: SHIP or NEEDS WORK
|
|
63
|
+
|
|
64
|
+
Be specific and constructive. Reference line numbers or function names when possible.`,
|
|
65
|
+
tools: ['file_read'],
|
|
66
|
+
maxTurns: 4,
|
|
67
|
+
timeoutMs: 120_000, // 2 min — local models can be slow
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// Progress handler
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
const taskTimes = new Map<string, number>()
|
|
75
|
+
|
|
76
|
+
function handleProgress(event: OrchestratorEvent): void {
|
|
77
|
+
const ts = new Date().toISOString().slice(11, 23)
|
|
78
|
+
|
|
79
|
+
switch (event.type) {
|
|
80
|
+
case 'task_start': {
|
|
81
|
+
taskTimes.set(event.task ?? '', Date.now())
|
|
82
|
+
const task = event.data as Task | undefined
|
|
83
|
+
console.log(`[${ts}] TASK READY "${task?.title ?? event.task}" → ${task?.assignee ?? '?'}`)
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
case 'task_complete': {
|
|
87
|
+
const elapsed = Date.now() - (taskTimes.get(event.task ?? '') ?? Date.now())
|
|
88
|
+
console.log(`[${ts}] TASK DONE task=${event.task} in ${elapsed}ms`)
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
case 'agent_start':
|
|
92
|
+
console.log(`[${ts}] AGENT START ${event.agent}`)
|
|
93
|
+
break
|
|
94
|
+
case 'agent_complete':
|
|
95
|
+
console.log(`[${ts}] AGENT DONE ${event.agent}`)
|
|
96
|
+
break
|
|
97
|
+
case 'error':
|
|
98
|
+
console.error(`[${ts}] ERROR ${event.agent ?? ''} task=${event.task ?? '?'}`)
|
|
99
|
+
break
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Orchestrator + Team
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
const orchestrator = new OpenMultiAgent({
|
|
108
|
+
defaultModel: 'claude-sonnet-4-6',
|
|
109
|
+
maxConcurrency: 2,
|
|
110
|
+
onProgress: handleProgress,
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const team = orchestrator.createTeam('local-cloud-team', {
|
|
114
|
+
name: 'local-cloud-team',
|
|
115
|
+
agents: [coder, reviewer],
|
|
116
|
+
sharedMemory: true,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// Task pipeline: code → review
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
const OUTPUT_DIR = '/tmp/local-model-demo'
|
|
124
|
+
|
|
125
|
+
const tasks: Array<{
|
|
126
|
+
title: string
|
|
127
|
+
description: string
|
|
128
|
+
assignee?: string
|
|
129
|
+
dependsOn?: string[]
|
|
130
|
+
}> = [
|
|
131
|
+
{
|
|
132
|
+
title: 'Write: retry utility',
|
|
133
|
+
description: `Write a small but complete TypeScript utility to ${OUTPUT_DIR}/retry.ts.
|
|
134
|
+
|
|
135
|
+
The module should export:
|
|
136
|
+
1. A \`RetryOptions\` interface with: maxRetries (number), delayMs (number),
|
|
137
|
+
backoffFactor (optional number, default 2), shouldRetry (optional predicate
|
|
138
|
+
taking the error and returning boolean).
|
|
139
|
+
2. An async \`retry<T>(fn: () => Promise<T>, options: RetryOptions): Promise<T>\`
|
|
140
|
+
function that retries \`fn\` with exponential backoff.
|
|
141
|
+
3. A convenience \`withRetry\` wrapper that returns a new function with retry
|
|
142
|
+
behaviour baked in.
|
|
143
|
+
|
|
144
|
+
Include JSDoc comments. No external dependencies — use only Node built-ins.
|
|
145
|
+
After writing the file, also create a small test script at ${OUTPUT_DIR}/retry-test.ts
|
|
146
|
+
that exercises the happy path and a failure case, then run it with \`npx tsx\`.`,
|
|
147
|
+
assignee: 'coder',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
title: 'Review: retry utility',
|
|
151
|
+
description: `Read the files at ${OUTPUT_DIR}/retry.ts and ${OUTPUT_DIR}/retry-test.ts.
|
|
152
|
+
|
|
153
|
+
Produce a structured code review covering:
|
|
154
|
+
- Summary (2-3 sentences describing the module)
|
|
155
|
+
- Strengths (bullet list)
|
|
156
|
+
- Issues (bullet list — be specific about what and why)
|
|
157
|
+
- Verdict: SHIP or NEEDS WORK`,
|
|
158
|
+
assignee: 'reviewer',
|
|
159
|
+
dependsOn: ['Write: retry utility'],
|
|
160
|
+
},
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Run
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
console.log('Local + Cloud model team')
|
|
168
|
+
console.log(` coder → Claude (${coder.model}) via Anthropic API`)
|
|
169
|
+
console.log(` reviewer → Ollama (${reviewer.model}) at ${reviewer.baseURL}`)
|
|
170
|
+
console.log()
|
|
171
|
+
console.log('Pipeline: coder writes code → local model reviews it')
|
|
172
|
+
console.log('='.repeat(60))
|
|
173
|
+
|
|
174
|
+
const result = await orchestrator.runTasks(team, tasks)
|
|
175
|
+
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
// Summary
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
console.log('\n' + '='.repeat(60))
|
|
181
|
+
console.log('Pipeline complete.\n')
|
|
182
|
+
console.log(`Overall success: ${result.success}`)
|
|
183
|
+
console.log(`Tokens — input: ${result.totalTokenUsage.input_tokens}, output: ${result.totalTokenUsage.output_tokens}`)
|
|
184
|
+
|
|
185
|
+
console.log('\nPer-agent summary:')
|
|
186
|
+
for (const [name, r] of result.agentResults) {
|
|
187
|
+
const icon = r.success ? 'OK ' : 'FAIL'
|
|
188
|
+
const provider = name === 'coder' ? 'anthropic' : 'ollama (local)'
|
|
189
|
+
const tools = r.toolCalls.map(c => c.toolName).join(', ')
|
|
190
|
+
console.log(` [${icon}] ${name.padEnd(10)} (${provider.padEnd(16)}) tools: ${tools || '(none)'}`)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Print the reviewer's output
|
|
194
|
+
const review = result.agentResults.get('reviewer')
|
|
195
|
+
if (review?.success) {
|
|
196
|
+
console.log('\nCode review (from local model):')
|
|
197
|
+
console.log('─'.repeat(60))
|
|
198
|
+
console.log(review.output)
|
|
199
|
+
console.log('─'.repeat(60))
|
|
200
|
+
}
|