@zelari/core 0.7.9
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/dist/agents/advancedTools.d.ts +7 -0
- package/dist/agents/advancedTools.d.ts.map +1 -0
- package/dist/agents/advancedTools.js +115 -0
- package/dist/agents/advancedTools.js.map +1 -0
- package/dist/agents/councilApi.d.ts +328 -0
- package/dist/agents/councilApi.d.ts.map +1 -0
- package/dist/agents/councilApi.js +952 -0
- package/dist/agents/councilApi.js.map +1 -0
- package/dist/agents/councilDirectives.d.ts +26 -0
- package/dist/agents/councilDirectives.d.ts.map +1 -0
- package/dist/agents/councilDirectives.js +98 -0
- package/dist/agents/councilDirectives.js.map +1 -0
- package/dist/agents/harnessToolBridge.d.ts +26 -0
- package/dist/agents/harnessToolBridge.d.ts.map +1 -0
- package/dist/agents/harnessToolBridge.js +60 -0
- package/dist/agents/harnessToolBridge.js.map +1 -0
- package/dist/agents/promoteMember.d.ts +77 -0
- package/dist/agents/promoteMember.d.ts.map +1 -0
- package/dist/agents/promoteMember.js +210 -0
- package/dist/agents/promoteMember.js.map +1 -0
- package/dist/agents/promptModules.d.ts +20 -0
- package/dist/agents/promptModules.d.ts.map +1 -0
- package/dist/agents/promptModules.js +139 -0
- package/dist/agents/promptModules.js.map +1 -0
- package/dist/agents/roles.d.ts +40 -0
- package/dist/agents/roles.d.ts.map +1 -0
- package/dist/agents/roles.js +352 -0
- package/dist/agents/roles.js.map +1 -0
- package/dist/agents/skills/builtin/debugging.d.ts +2 -0
- package/dist/agents/skills/builtin/debugging.d.ts.map +1 -0
- package/dist/agents/skills/builtin/debugging.js +248 -0
- package/dist/agents/skills/builtin/debugging.js.map +1 -0
- package/dist/agents/skills/builtin/docs.d.ts +2 -0
- package/dist/agents/skills/builtin/docs.d.ts.map +1 -0
- package/dist/agents/skills/builtin/docs.js +291 -0
- package/dist/agents/skills/builtin/docs.js.map +1 -0
- package/dist/agents/skills/builtin/git-ops.d.ts +2 -0
- package/dist/agents/skills/builtin/git-ops.d.ts.map +1 -0
- package/dist/agents/skills/builtin/git-ops.js +301 -0
- package/dist/agents/skills/builtin/git-ops.js.map +1 -0
- package/dist/agents/skills/builtin/planning.d.ts +2 -0
- package/dist/agents/skills/builtin/planning.d.ts.map +1 -0
- package/dist/agents/skills/builtin/planning.js +335 -0
- package/dist/agents/skills/builtin/planning.js.map +1 -0
- package/dist/agents/skills/builtin/refactoring.d.ts +2 -0
- package/dist/agents/skills/builtin/refactoring.d.ts.map +1 -0
- package/dist/agents/skills/builtin/refactoring.js +261 -0
- package/dist/agents/skills/builtin/refactoring.js.map +1 -0
- package/dist/agents/skills/builtin/review.d.ts +2 -0
- package/dist/agents/skills/builtin/review.d.ts.map +1 -0
- package/dist/agents/skills/builtin/review.js +302 -0
- package/dist/agents/skills/builtin/review.js.map +1 -0
- package/dist/agents/skills/builtin/testing.d.ts +2 -0
- package/dist/agents/skills/builtin/testing.d.ts.map +1 -0
- package/dist/agents/skills/builtin/testing.js +245 -0
- package/dist/agents/skills/builtin/testing.js.map +1 -0
- package/dist/agents/skills.d.ts +138 -0
- package/dist/agents/skills.d.ts.map +1 -0
- package/dist/agents/skills.js +277 -0
- package/dist/agents/skills.js.map +1 -0
- package/dist/agents/systemPromptBuilder.d.ts +45 -0
- package/dist/agents/systemPromptBuilder.d.ts.map +1 -0
- package/dist/agents/systemPromptBuilder.js +159 -0
- package/dist/agents/systemPromptBuilder.js.map +1 -0
- package/dist/agents/toolSchemas.d.ts +55 -0
- package/dist/agents/toolSchemas.d.ts.map +1 -0
- package/dist/agents/toolSchemas.js +316 -0
- package/dist/agents/toolSchemas.js.map +1 -0
- package/dist/agents/tools.d.ts +67 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +225 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/vaultTools.d.ts +9 -0
- package/dist/agents/vaultTools.d.ts.map +1 -0
- package/dist/agents/vaultTools.js +134 -0
- package/dist/agents/vaultTools.js.map +1 -0
- package/dist/core/AgentHarness.d.ts +250 -0
- package/dist/core/AgentHarness.d.ts.map +1 -0
- package/dist/core/AgentHarness.js +614 -0
- package/dist/core/AgentHarness.js.map +1 -0
- package/dist/core/providerStream.d.ts +61 -0
- package/dist/core/providerStream.d.ts.map +1 -0
- package/dist/core/providerStream.js +99 -0
- package/dist/core/providerStream.js.map +1 -0
- package/dist/core/sessionJsonl.d.ts +50 -0
- package/dist/core/sessionJsonl.d.ts.map +1 -0
- package/dist/core/sessionJsonl.js +99 -0
- package/dist/core/sessionJsonl.js.map +1 -0
- package/dist/core/tools/auditLog.d.ts +14 -0
- package/dist/core/tools/auditLog.d.ts.map +1 -0
- package/dist/core/tools/auditLog.js +26 -0
- package/dist/core/tools/auditLog.js.map +1 -0
- package/dist/core/tools/builtin/_walk.d.ts +40 -0
- package/dist/core/tools/builtin/_walk.d.ts.map +1 -0
- package/dist/core/tools/builtin/_walk.js +129 -0
- package/dist/core/tools/builtin/_walk.js.map +1 -0
- package/dist/core/tools/builtin/diff.d.ts +45 -0
- package/dist/core/tools/builtin/diff.d.ts.map +1 -0
- package/dist/core/tools/builtin/diff.js +477 -0
- package/dist/core/tools/builtin/diff.js.map +1 -0
- package/dist/core/tools/builtin/filesystem.d.ts +45 -0
- package/dist/core/tools/builtin/filesystem.d.ts.map +1 -0
- package/dist/core/tools/builtin/filesystem.js +110 -0
- package/dist/core/tools/builtin/filesystem.js.map +1 -0
- package/dist/core/tools/builtin/listFiles.d.ts +18 -0
- package/dist/core/tools/builtin/listFiles.d.ts.map +1 -0
- package/dist/core/tools/builtin/listFiles.js +48 -0
- package/dist/core/tools/builtin/listFiles.js.map +1 -0
- package/dist/core/tools/builtin/search.d.ts +49 -0
- package/dist/core/tools/builtin/search.d.ts.map +1 -0
- package/dist/core/tools/builtin/search.js +148 -0
- package/dist/core/tools/builtin/search.js.map +1 -0
- package/dist/core/tools/builtin/shell.d.ts +27 -0
- package/dist/core/tools/builtin/shell.d.ts.map +1 -0
- package/dist/core/tools/builtin/shell.js +98 -0
- package/dist/core/tools/builtin/shell.js.map +1 -0
- package/dist/core/tools/builtin/shellResolver.d.ts +25 -0
- package/dist/core/tools/builtin/shellResolver.d.ts.map +1 -0
- package/dist/core/tools/builtin/shellResolver.js +117 -0
- package/dist/core/tools/builtin/shellResolver.js.map +1 -0
- package/dist/core/tools/builtin/web.d.ts +43 -0
- package/dist/core/tools/builtin/web.d.ts.map +1 -0
- package/dist/core/tools/builtin/web.js +208 -0
- package/dist/core/tools/builtin/web.js.map +1 -0
- package/dist/core/tools/registry.d.ts +31 -0
- package/dist/core/tools/registry.d.ts.map +1 -0
- package/dist/core/tools/registry.js +115 -0
- package/dist/core/tools/registry.js.map +1 -0
- package/dist/core/tools/toolTypes.d.ts +60 -0
- package/dist/core/tools/toolTypes.d.ts.map +1 -0
- package/dist/core/tools/toolTypes.js +8 -0
- package/dist/core/tools/toolTypes.js.map +1 -0
- package/dist/core/tools/zodBridge.d.ts +6 -0
- package/dist/core/tools/zodBridge.d.ts.map +1 -0
- package/dist/core/tools/zodBridge.js +56 -0
- package/dist/core/tools/zodBridge.js.map +1 -0
- package/dist/council/index.d.ts +14 -0
- package/dist/council/index.d.ts.map +1 -0
- package/dist/council/index.js +14 -0
- package/dist/council/index.js.map +1 -0
- package/dist/council/modeBanners.d.ts +5 -0
- package/dist/council/modeBanners.d.ts.map +1 -0
- package/dist/council/modeBanners.js +10 -0
- package/dist/council/modeBanners.js.map +1 -0
- package/dist/council/runMode.d.ts +25 -0
- package/dist/council/runMode.d.ts.map +1 -0
- package/dist/council/runMode.js +41 -0
- package/dist/council/runMode.js.map +1 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +6 -0
- package/dist/events/index.js.map +1 -0
- package/dist/harness/index.d.ts +9 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +9 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/tools/index.d.ts +20 -0
- package/dist/harness/tools/index.d.ts.map +1 -0
- package/dist/harness/tools/index.js +19 -0
- package/dist/harness/tools/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/eventBus.d.ts +58 -0
- package/dist/shared/eventBus.d.ts.map +1 -0
- package/dist/shared/eventBus.js +104 -0
- package/dist/shared/eventBus.js.map +1 -0
- package/dist/shared/events.d.ts +230 -0
- package/dist/shared/events.d.ts.map +1 -0
- package/dist/shared/events.js +76 -0
- package/dist/shared/events.js.map +1 -0
- package/dist/shared/index.d.ts +8 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +8 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/skills/index.d.ts +10 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +10 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/types/context.d.ts +54 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +3 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knowledge.d.ts +79 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +5 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/legacy.d.ts +466 -0
- package/dist/types/legacy.d.ts.map +1 -0
- package/dist/types/legacy.js +2 -0
- package/dist/types/legacy.js.map +1 -0
- package/dist/types/systemTypes.d.ts +113 -0
- package/dist/types/systemTypes.d.ts.map +1 -0
- package/dist/types/systemTypes.js +10 -0
- package/dist/types/systemTypes.js.map +1 -0
- package/package.json +151 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentHarness — provider-neutral agent loop.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates a single agent turn: given a (model, provider, messages, tools)
|
|
5
|
+
* configuration and a provider streaming function, it drives the stream and
|
|
6
|
+
* yields the full {@link BrainEvent} lifecycle as an `AsyncIterable<BrainEvent>`.
|
|
7
|
+
*
|
|
8
|
+
* Electron-free: this module imports ONLY from `electron/shared/` (the event
|
|
9
|
+
* contract + bus) and `electron/main/core/tools/` (the tool registry). It has
|
|
10
|
+
* zero coupling to `llm.ts` or any main-process IPC, so it can run in the
|
|
11
|
+
* Electron main process today and be reused from the Ink CLI in Phase 14.
|
|
12
|
+
*
|
|
13
|
+
* When `toolRegistry` is provided, tool_call deltas trigger real tool
|
|
14
|
+
* execution and emit a matching `tool_execution_end` event. Without it, the
|
|
15
|
+
* harness only emits `tool_execution_start` (legacy behavior, useful for
|
|
16
|
+
* streaming-only consumers).
|
|
17
|
+
*
|
|
18
|
+
* @see docs/plans/2026-06-28-zelari-code.md (Task 12.1 + 14.8)
|
|
19
|
+
*/
|
|
20
|
+
import { EventBus } from '../shared/eventBus.js';
|
|
21
|
+
import { type BrainEvent, type UsageBreakdown } from '../shared/events.js';
|
|
22
|
+
import { ToolRegistry } from './tools/registry.js';
|
|
23
|
+
export interface AgentMessage {
|
|
24
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
25
|
+
content: string;
|
|
26
|
+
/** For tool messages: the tool call id this result corresponds to. */
|
|
27
|
+
toolCallId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* For assistant messages that requested tool calls: the list of tool
|
|
30
|
+
* invocations the model emitted in this turn. The provider maps this to
|
|
31
|
+
* OpenAI `tool_calls` so a subsequent request can continue the conversation
|
|
32
|
+
* after tool results are appended.
|
|
33
|
+
*/
|
|
34
|
+
toolCalls?: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
args: Record<string, unknown>;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
export interface AgentToolSpec {
|
|
41
|
+
/** Tool name (must match the tool registry). */
|
|
42
|
+
name: string;
|
|
43
|
+
/** JSON-schema-like description for the LLM. */
|
|
44
|
+
description: string;
|
|
45
|
+
/** JSON Schema for the tool's input arguments. */
|
|
46
|
+
parameters: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
export interface AgentHarnessConfig {
|
|
49
|
+
/** Model identifier (e.g. 'grok-4', 'MiniMax-M2.5'). */
|
|
50
|
+
model: string;
|
|
51
|
+
/** Provider id (e.g. 'grok', 'minimax', 'glm', 'custom'). */
|
|
52
|
+
provider: string;
|
|
53
|
+
/** Conversation transcript (system prompt is composed by the caller). */
|
|
54
|
+
messages: AgentMessage[];
|
|
55
|
+
/** Tools available to the agent (may be empty). */
|
|
56
|
+
tools: AgentToolSpec[];
|
|
57
|
+
/** Optional event bus. When omitted, events are silently dropped. */
|
|
58
|
+
eventBus?: EventBus;
|
|
59
|
+
/** Optional session id for event grouping. Defaults to a UUID. */
|
|
60
|
+
sessionId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Provider function that yields raw text deltas + finish reason.
|
|
63
|
+
* Implementation in Task 12.5 (currently lives in llm.ts).
|
|
64
|
+
*/
|
|
65
|
+
providerStream: ProviderStreamFn;
|
|
66
|
+
/**
|
|
67
|
+
* Optional tool registry. When provided, tool_call deltas trigger real
|
|
68
|
+
* tool execution and emit a matching `tool_execution_end` event.
|
|
69
|
+
*/
|
|
70
|
+
toolRegistry?: ToolRegistry;
|
|
71
|
+
/** Optional cwd for tool execution. Defaults to process.cwd(). */
|
|
72
|
+
cwd?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Maximum tool calls per single turn (Task G.2, carryover from v3-C
|
|
75
|
+
* C.1.5). When the harness sees more than this many `tool_call`
|
|
76
|
+
* deltas in a single turn, the extra ones are NOT executed by the
|
|
77
|
+
* registry — instead a synthetic `tool_execution_end` event is
|
|
78
|
+
* emitted with `isError: true, result: '[skipped] maxToolCallsPerTurn
|
|
79
|
+
* reached'`. The `tool_execution_start` event still fires so the UI
|
|
80
|
+
* can render the tool attempt.
|
|
81
|
+
*
|
|
82
|
+
* Default: undefined (no limit — backward compatible with v3-C behavior).
|
|
83
|
+
* Council sets it to 5 by default via `PureCouncilConfig.maxToolCallsPerTurn`.
|
|
84
|
+
*
|
|
85
|
+
* Mitigation rationale: a council member prompted with "explore the repo"
|
|
86
|
+
* could otherwise fire 50 read_file calls in one turn, ballooning the
|
|
87
|
+
* message context to the point where the next provider call fails with
|
|
88
|
+
* HTTP 400 (context length exceeded).
|
|
89
|
+
*/
|
|
90
|
+
maxToolCallsPerTurn?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Maximum number of drained queued prompts per run() invocation.
|
|
93
|
+
* When the queue is non-empty after a turn, the harness re-enters
|
|
94
|
+
* the providerStream loop up to this many times before yielding
|
|
95
|
+
* agent_end. Default 3. Set to 0 to disable queue draining.
|
|
96
|
+
*/
|
|
97
|
+
maxQueuedIterations?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Optional council-member identity, propagated to every event the
|
|
100
|
+
* harness emits (`agent_start`, `agent_end`, `message_start`,
|
|
101
|
+
* `message_delta`, `message_end`). When set, the event stream
|
|
102
|
+
* becomes self-describing for visible-reasoning UIs.
|
|
103
|
+
*
|
|
104
|
+
* Direct user prompts (non-council) leave this undefined.
|
|
105
|
+
*
|
|
106
|
+
* @since 0.5.0
|
|
107
|
+
*/
|
|
108
|
+
memberId?: string;
|
|
109
|
+
/** Human-readable member label (e.g. "Caronte"). See `memberId`. */
|
|
110
|
+
memberName?: string;
|
|
111
|
+
}
|
|
112
|
+
export type ProviderStreamFn = (params: {
|
|
113
|
+
messages: AgentMessage[];
|
|
114
|
+
model: string;
|
|
115
|
+
provider: string;
|
|
116
|
+
tools: AgentToolSpec[];
|
|
117
|
+
signal?: AbortSignal;
|
|
118
|
+
}) => AsyncIterable<ProviderDelta>;
|
|
119
|
+
/** Provider-neutral streaming delta (one chunk from a provider). */
|
|
120
|
+
export type ProviderDelta = {
|
|
121
|
+
kind: 'text';
|
|
122
|
+
delta: string;
|
|
123
|
+
} | {
|
|
124
|
+
kind: 'thinking';
|
|
125
|
+
delta: string;
|
|
126
|
+
} | {
|
|
127
|
+
kind: 'tool_call';
|
|
128
|
+
toolCallId: string;
|
|
129
|
+
toolName: string;
|
|
130
|
+
args: Record<string, unknown>;
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'finish';
|
|
133
|
+
reason: string;
|
|
134
|
+
} | {
|
|
135
|
+
kind: 'error';
|
|
136
|
+
message: string;
|
|
137
|
+
}
|
|
138
|
+
/** Provider-reported token usage (Task G.4). Emitted as a standalone
|
|
139
|
+
* delta so it can arrive anywhere in the stream — typically right
|
|
140
|
+
* before `[DONE]` when `stream_options.include_usage` is set. */
|
|
141
|
+
| {
|
|
142
|
+
kind: 'usage';
|
|
143
|
+
usage: UsageBreakdown;
|
|
144
|
+
};
|
|
145
|
+
export declare class AgentHarness {
|
|
146
|
+
private readonly config;
|
|
147
|
+
private readonly eventBus;
|
|
148
|
+
private readonly sessionId;
|
|
149
|
+
private readonly maxQueuedIterations;
|
|
150
|
+
private cancelled;
|
|
151
|
+
private activeController;
|
|
152
|
+
private queue;
|
|
153
|
+
/**
|
|
154
|
+
* Per-run cache of executed tool calls keyed by `hash(toolName + canonical
|
|
155
|
+
* args)`. v0.7.1 (A2): when the model re-issues an identical call (a
|
|
156
|
+
* observed failure mode where read_file hit the same path ×3 / cat the
|
|
157
|
+
* same file ×3), the cached result is replayed with a "duplicate call"
|
|
158
|
+
* prefix instead of re-executing — preserving the iteration budget for
|
|
159
|
+
* real progress. Reset on every `run()` so it does not leak across turns.
|
|
160
|
+
*/
|
|
161
|
+
private toolCallCache;
|
|
162
|
+
constructor(config: AgentHarnessConfig);
|
|
163
|
+
/**
|
|
164
|
+
* Member identity fields (memberId + memberName) to merge into every
|
|
165
|
+
* event payload. Returns an empty object when the run is a direct
|
|
166
|
+
* user prompt (no member context), so call sites can spread it
|
|
167
|
+
* unconditionally.
|
|
168
|
+
*
|
|
169
|
+
* @since 0.5.0
|
|
170
|
+
*/
|
|
171
|
+
private memberFields;
|
|
172
|
+
/**
|
|
173
|
+
* Cancel the in-flight run. Events drain until end of stream.
|
|
174
|
+
*
|
|
175
|
+
* Idempotent: calling cancel() multiple times is safe — the cancelled
|
|
176
|
+
* flag stays true and AbortController.abort() is itself a no-op on
|
|
177
|
+
* already-aborted controllers. If no turn is running, this is a
|
|
178
|
+
* no-op (the next run() invocation will check the cancelled flag
|
|
179
|
+
* and emit `agent_end` with `reason: 'cancelled'` before any work).
|
|
180
|
+
*
|
|
181
|
+
* After cancel() returns, the harness should be discarded by the
|
|
182
|
+
* caller (the run() generator finishes after the current turn ends).
|
|
183
|
+
* For mid-stream interrupt + new-prompt injection, see Task C.3.2.
|
|
184
|
+
*/
|
|
185
|
+
cancel(): void;
|
|
186
|
+
/** Current size of the queued user-prompt buffer. */
|
|
187
|
+
get queueLength(): number;
|
|
188
|
+
/**
|
|
189
|
+
* Enqueue a user prompt to be processed at the next opportunity.
|
|
190
|
+
* The next prompt in the queue will be appended to the conversation
|
|
191
|
+
* transcript and re-enter the provider stream loop after the current
|
|
192
|
+
* turn finishes. Emits a `queue_update` event so UIs can refresh
|
|
193
|
+
* the displayed counter.
|
|
194
|
+
*
|
|
195
|
+
* If `run()` has already returned (no active loop), the queued
|
|
196
|
+
* prompt will be picked up on the *next* run() call — note this
|
|
197
|
+
* helper does NOT itself trigger a run. Callers wire the
|
|
198
|
+
* dequeue step inside `run()` (Task 18.1).
|
|
199
|
+
*/
|
|
200
|
+
enqueue(userText: string): void;
|
|
201
|
+
/**
|
|
202
|
+
* Dequeue the next queued prompt, or `null` if the queue is empty.
|
|
203
|
+
* Emits a `queue_update` event with the new length so UIs can
|
|
204
|
+
* decrement the counter.
|
|
205
|
+
*/
|
|
206
|
+
dequeueNext(): string | null;
|
|
207
|
+
/**
|
|
208
|
+
* Run a single agent turn and yield provider-neutral BrainEvents.
|
|
209
|
+
* The returned AsyncIterable emits all BrainEvents for the run, then completes.
|
|
210
|
+
* Callers can subscribe via eventBus AND iterate the returned iterable.
|
|
211
|
+
*/
|
|
212
|
+
run(): AsyncIterable<BrainEvent>;
|
|
213
|
+
/**
|
|
214
|
+
* Run a single provider turn for the current message buffer.
|
|
215
|
+
* Streams from the provider, dispatches deltas to events, executes
|
|
216
|
+
* any tool calls (if a registry was provided). Yields each
|
|
217
|
+
* `BrainEvent` it produces so the caller can re-emit them in
|
|
218
|
+
* the outer generator.
|
|
219
|
+
*
|
|
220
|
+
* Does NOT emit `message_start` / `message_end` — those are the
|
|
221
|
+
* caller's responsibility (so the outer generator can wrap them
|
|
222
|
+
* around the yielded event stream and compute the right
|
|
223
|
+
* `totalLength` from observed deltas).
|
|
224
|
+
*
|
|
225
|
+
* Extracted from the original monolithic `run()` body to enable
|
|
226
|
+
* the queue-draining loop in Task 18.1.
|
|
227
|
+
*/
|
|
228
|
+
private runSingleTurn;
|
|
229
|
+
private emit;
|
|
230
|
+
/**
|
|
231
|
+
* Final-answer turn (v0.7.1 A2). Called when the tool-call loop hit its
|
|
232
|
+
* iteration cap without the model producing a non-tool finish. Makes ONE
|
|
233
|
+
* provider call with `tools` OMITTED and a synthetic system nudge appended,
|
|
234
|
+
* so the run always ends with assistant text answering the user with what
|
|
235
|
+
* has been gathered — instead of trailing off after the last tool box.
|
|
236
|
+
*
|
|
237
|
+
* Yields the full message lifecycle (start/deltas/end) so the UI renders
|
|
238
|
+
* the closing answer like any other assistant turn. Errors are swallowed
|
|
239
|
+
* into a recoverable error event (best-effort: the guarantee must never
|
|
240
|
+
* turn a near-success into a hard failure).
|
|
241
|
+
*/
|
|
242
|
+
private runFinalAnswerTurn;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Stable hash key for a tool call (v0.7.1 A2). Canonicalizes args via a sorted
|
|
246
|
+
* JSON.stringify so `{a:1,b:2}` and `{b:2,a:1}` collide (same logical call).
|
|
247
|
+
* Exported for unit tests.
|
|
248
|
+
*/
|
|
249
|
+
export declare function hashToolCall(toolName: string, args: unknown): string;
|
|
250
|
+
//# sourceMappingURL=AgentHarness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentHarness.d.ts","sourceRoot":"","sources":["../../src/core/AgentHarness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAEL,KAAK,UAAU,EAQf,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;CAC3E;AAED,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,mDAAmD;IACnD,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,kEAAkE;IAClE,SAAS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