@zelari/core 2.33.0 → 2.34.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/README.md +1 -1
- package/dist/agents/council/chairmanDelivery.d.ts +92 -0
- package/dist/agents/council/chairmanDelivery.d.ts.map +1 -0
- package/dist/agents/council/chairmanDelivery.js +226 -0
- package/dist/agents/council/chairmanDelivery.js.map +1 -0
- package/dist/agents/council/chairmanFixLoop.d.ts +47 -0
- package/dist/agents/council/chairmanFixLoop.d.ts.map +1 -0
- package/dist/agents/council/chairmanFixLoop.js +127 -0
- package/dist/agents/council/chairmanFixLoop.js.map +1 -0
- package/dist/agents/council/memberMessages.d.ts +32 -0
- package/dist/agents/council/memberMessages.d.ts.map +1 -0
- package/dist/agents/council/memberMessages.js +95 -0
- package/dist/agents/council/memberMessages.js.map +1 -0
- package/dist/agents/council/outputCleaning.d.ts +37 -0
- package/dist/agents/council/outputCleaning.d.ts.map +1 -0
- package/dist/agents/council/outputCleaning.js +150 -0
- package/dist/agents/council/outputCleaning.js.map +1 -0
- package/dist/agents/council/retryTurn.d.ts +128 -0
- package/dist/agents/council/retryTurn.d.ts.map +1 -0
- package/dist/agents/council/retryTurn.js +200 -0
- package/dist/agents/council/retryTurn.js.map +1 -0
- package/dist/agents/council/toolEmission.d.ts +61 -0
- package/dist/agents/council/toolEmission.d.ts.map +1 -0
- package/dist/agents/council/toolEmission.js +110 -0
- package/dist/agents/council/toolEmission.js.map +1 -0
- package/dist/agents/council/types.d.ts +184 -0
- package/dist/agents/council/types.d.ts.map +1 -0
- package/dist/agents/council/types.js +15 -0
- package/dist/agents/council/types.js.map +1 -0
- package/dist/agents/councilApi.d.ts +11 -526
- package/dist/agents/councilApi.d.ts.map +1 -1
- package/dist/agents/councilApi.js +19 -893
- package/dist/agents/councilApi.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,238 +1,12 @@
|
|
|
1
|
-
import type { AgentRole } from '../types/index.js';
|
|
2
|
-
import { type ParsedToolCall } from './toolSchemas.js';
|
|
3
|
-
import type { SystemPromptConfig, SystemPromptModule } from '../types/systemTypes.js';
|
|
4
1
|
import type { BrainEvent } from '../shared/events.js';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { type MicroGateWarning } from '../council/verification/microGate.js';
|
|
9
|
-
/**
|
|
10
|
-
* Council members whose tool-emission retry is DISABLED.
|
|
11
|
-
*
|
|
12
|
-
* v0.7.7 Opzione B put 'nettun' here because its contract (12 createTask
|
|
13
|
-
* + 1 createMilestone = 13+ sequential calls) exceeded what composer-2.5
|
|
14
|
-
* could persist in the 240s budget, making the retry a pure waste.
|
|
15
|
-
*
|
|
16
|
-
* v0.7.8 removes 'nettun': the plan contract is now satisfiable with a
|
|
17
|
-
* SINGLE `createPlan` batch call (phases + nested tasks + milestone in
|
|
18
|
-
* one emission), so the forced retry has the same 1-call budget that
|
|
19
|
-
* already works reliably for Minosse and Lucifero. The set stays
|
|
20
|
-
* exported as the opt-out mechanism for future members.
|
|
21
|
-
*/
|
|
22
|
-
export declare const NON_RETRY_AGENTS: ReadonlySet<string>;
|
|
2
|
+
import type { PureCouncilConfig, PureCouncilCallbacks } from './council/types.js';
|
|
3
|
+
export { NON_RETRY_AGENTS } from './council/types.js';
|
|
4
|
+
export type { FeedbackStoreLike, PureCouncilConfig, PureCouncilCallbacks } from './council/types.js';
|
|
23
5
|
export type { BrainEvent } from '../shared/events.js';
|
|
24
6
|
export type { AgentMessage, AgentToolSpec, ProviderStreamFn, ProviderDelta, } from '../core/AgentHarness.js';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* importing it (keeps the core free of CLI-side deps).
|
|
29
|
-
*
|
|
30
|
-
* Used by `runCouncilPure` to opt-in to feedback-driven specialist ordering
|
|
31
|
-
* via the `.ranked()` method (Task: council integration, v3-I deferred).
|
|
32
|
-
*/
|
|
33
|
-
export interface FeedbackStoreLike {
|
|
34
|
-
/**
|
|
35
|
-
* Return a NEW array sorted by feedback score, descending.
|
|
36
|
-
* Members with no feedback are placed last, ordered by id ascending.
|
|
37
|
-
*/
|
|
38
|
-
ranked<T extends {
|
|
39
|
-
id: string;
|
|
40
|
-
}>(items: T[]): T[];
|
|
41
|
-
}
|
|
42
|
-
export interface PureCouncilConfig {
|
|
43
|
-
apiKey: string;
|
|
44
|
-
glmApiKey?: string;
|
|
45
|
-
provider?: string;
|
|
46
|
-
model: string;
|
|
47
|
-
councilSize: number;
|
|
48
|
-
debateMode: boolean;
|
|
49
|
-
ragContext: string;
|
|
50
|
-
workspaceContext: string;
|
|
51
|
-
completedAgentIds?: string[];
|
|
52
|
-
existingOutputs?: {
|
|
53
|
-
name: string;
|
|
54
|
-
role: string;
|
|
55
|
-
content: string;
|
|
56
|
-
}[];
|
|
57
|
-
aiConfig?: SystemPromptConfig;
|
|
58
|
-
agentModels?: Record<string, {
|
|
59
|
-
providerId: string;
|
|
60
|
-
model: string;
|
|
61
|
-
}>;
|
|
62
|
-
customProviders?: Array<{
|
|
63
|
-
id: string;
|
|
64
|
-
baseUrl: string;
|
|
65
|
-
authStyle: 'openai' | 'anthropic';
|
|
66
|
-
models: string[];
|
|
67
|
-
}>;
|
|
68
|
-
providerApiKeys?: Record<string, string>;
|
|
69
|
-
/**
|
|
70
|
-
* Optional per-call member remap (Task I.3 close-out).
|
|
71
|
-
*
|
|
72
|
-
* When set (non-empty), `swapMembers(agents, memberSwap)` is applied
|
|
73
|
-
* immediately after `getCouncilAgents()` and BEFORE filtering into
|
|
74
|
-
* specialists / oracle / chairman. Useful for replacing `oracle` with a
|
|
75
|
-
* custom critic on the fly. Throws `UnknownMemberError` on typo in either
|
|
76
|
-
* side of the mapping.
|
|
77
|
-
*
|
|
78
|
-
* Backward-compat: when omitted, behavior is identical to pre-integration.
|
|
79
|
-
*
|
|
80
|
-
* @see swapMembers in src/agents/roles.ts
|
|
81
|
-
*/
|
|
82
|
-
memberSwap?: Record<string, string>;
|
|
83
|
-
/**
|
|
84
|
-
* Optional feedback store for specialist ordering (Task I.2 close-out).
|
|
85
|
-
*
|
|
86
|
-
* When set, `feedbackStore.ranked(specialists)` is applied AFTER the swap
|
|
87
|
-
* filter and BEFORE the specialists loop. Only specialists are ranked —
|
|
88
|
-
* oracle (debate-mode review) and chairman (synthesis) keep their fixed
|
|
89
|
-
* positions. This preserves the existing semantics of the council while
|
|
90
|
-
* letting good-rated specialists go first.
|
|
91
|
-
*
|
|
92
|
-
* Backward-compat: when omitted, specialists run in their default order.
|
|
93
|
-
*/
|
|
94
|
-
feedbackStore?: FeedbackStoreLike;
|
|
95
|
-
/** Provider stream function (injected for testability). MUST yield ProviderDelta. */
|
|
96
|
-
providerStream: ProviderStreamFn;
|
|
97
|
-
/** Optional event bus for emitting BrainEvents alongside the returned iterable. */
|
|
98
|
-
eventBus?: import('../shared/eventBus.js').EventBus;
|
|
99
|
-
/** Optional session id. Defaults to a UUID. */
|
|
100
|
-
sessionId?: string;
|
|
101
|
-
/**
|
|
102
|
-
* Optional tool registry. When provided, each council member (specialist
|
|
103
|
-
* and oracle) is given access to the registry via AgentHarness — tool_call
|
|
104
|
-
* deltas trigger real tool execution and emit tool_execution_end events.
|
|
105
|
-
* Without it, the council is text-only (legacy behavior).
|
|
106
|
-
*
|
|
107
|
-
* @see electron/main/core/AgentHarness.ts — `toolRegistry` field
|
|
108
|
-
* @see electron/cli/toolRegistry.ts — `createBuiltinToolRegistry()`
|
|
109
|
-
*/
|
|
110
|
-
tools?: ToolRegistry;
|
|
111
|
-
/**
|
|
112
|
-
* Max tool calls per member per turn. Enforced by truncating extra
|
|
113
|
-
* tool_execution_start events to `tool_call_skipped` after this limit.
|
|
114
|
-
* Default: 5. Set to 0 to disable tools entirely (overrides `tools`).
|
|
115
|
-
*/
|
|
116
|
-
maxToolCallsPerTurn?: number;
|
|
117
|
-
/**
|
|
118
|
-
* Override the tool-call budget for the chairman (Lucifero) only. Zelari-mode
|
|
119
|
-
* raises this for long autonomous implementation runs while leaving the
|
|
120
|
-
* specialists and oracle on the shared `maxToolCallsPerTurn`. Falls back to
|
|
121
|
-
* `maxToolCallsPerTurn`, then 5.
|
|
122
|
-
*/
|
|
123
|
-
maxToolCallsChairman?: number;
|
|
124
|
-
/**
|
|
125
|
-
* Soft max observe→reason→act cycles per member harness run.
|
|
126
|
-
* Forwarded to AgentHarness; default is the harness default (30) when unset.
|
|
127
|
-
* CLI wires this from `ZELARI_MAX_TOOL_LOOP_ITERATIONS`.
|
|
128
|
-
*/
|
|
129
|
-
maxToolLoopIterations?: number;
|
|
130
|
-
/**
|
|
131
|
-
* Hard ceiling on tool-loop iterations per member. `0`/unset → harness
|
|
132
|
-
* computes max(soft×3, soft+60). CLI: `ZELARI_MAX_TOOL_LOOP_HARD`.
|
|
133
|
-
*/
|
|
134
|
-
maxToolLoopHardCap?: number;
|
|
135
|
-
/**
|
|
136
|
-
* When true, skip all specialists (Caronte…Plutone). Only Minosse (oracle)
|
|
137
|
-
* and Lucifero (chairman) run. Used by Zelari mission implementer-retry
|
|
138
|
-
* slices (implementation 2+) so fix/verify loops do not re-pay a full
|
|
139
|
-
* 6-member council. Default false — full roster.
|
|
140
|
-
*/
|
|
141
|
-
skipSpecialists?: boolean;
|
|
142
|
-
/** Council run mode. Default: `implementation`. */
|
|
143
|
-
runMode?: CouncilRunMode;
|
|
144
|
-
}
|
|
145
|
-
export interface PureCouncilCallbacks {
|
|
146
|
-
/** Status lines surfaced in the TUI (delivery retries, verify passes). */
|
|
147
|
-
onCouncilStatus?: (message: string) => void;
|
|
148
|
-
onAgentStart?: (agent: AgentRole) => void;
|
|
149
|
-
onAgentChunk?: (agent: AgentRole, chunk: string) => void;
|
|
150
|
-
onAgentDone?: (agent: AgentRole, content: string, thinking?: string) => void;
|
|
151
|
-
onSynthesisStart?: () => void;
|
|
152
|
-
onSynthesisChunk?: (chunk: string) => void;
|
|
153
|
-
onSynthesisDone?: (content: string, toolCalls?: ParsedToolCall[], thinking?: string) => void;
|
|
154
|
-
/**
|
|
155
|
-
* Fired after every council member (specialist, oracle, chairman) completes
|
|
156
|
-
* its run, with the accumulated cost for that member (Task I.1, v3-I).
|
|
157
|
-
* The same payload is also yielded as a `member_cost` BrainEvent in the
|
|
158
|
-
* main event stream so JSONL sidecars and live consumers stay consistent.
|
|
159
|
-
*
|
|
160
|
-
* When the provider does not send `usage` (some don't honor
|
|
161
|
-
* `stream_options.include_usage`), the token fields are 0. Tool calls
|
|
162
|
-
* are counted from `tool_execution_start` events. Duration is wall-clock
|
|
163
|
-
* around the member's AgentHarness run.
|
|
164
|
-
*/
|
|
165
|
-
onMemberCost?: (cost: {
|
|
166
|
-
memberId: string;
|
|
167
|
-
name: string;
|
|
168
|
-
promptTokens: number;
|
|
169
|
-
completionTokens: number;
|
|
170
|
-
totalTokens: number;
|
|
171
|
-
durationMs: number;
|
|
172
|
-
toolCalls: number;
|
|
173
|
-
errored: boolean;
|
|
174
|
-
}) => void;
|
|
175
|
-
/**
|
|
176
|
-
* v1.8.0: when a member emits a structured ---QUESTION--- with choices,
|
|
177
|
-
* the CLI may pause and ask the user (SelectList). Return the chosen
|
|
178
|
-
* answer (or null if cancelled / free-text will follow later). Injected
|
|
179
|
-
* into agentOutputs so subsequent members see the reply.
|
|
180
|
-
*/
|
|
181
|
-
onClarification?: (req: ClarificationRequest) => Promise<string | null | undefined>;
|
|
182
|
-
}
|
|
183
|
-
export interface ClarificationRequest {
|
|
184
|
-
question: string;
|
|
185
|
-
choices?: string[];
|
|
186
|
-
context?: string;
|
|
187
|
-
}
|
|
188
|
-
export declare function parseClarificationRequest(text: string): ClarificationRequest | null;
|
|
189
|
-
/** True when text contains a structured question with ≥2 choices (pause UI). */
|
|
190
|
-
export declare function hasInteractiveClarification(text: string): boolean;
|
|
191
|
-
export declare function parseThinking(text: string): string;
|
|
192
|
-
export interface CleanAgentContentOptions {
|
|
193
|
-
/**
|
|
194
|
-
* When true (default), strip `---QUESTION---` blocks from display text.
|
|
195
|
-
* Set false when cleaning text for rolling PROVIDER history — the model
|
|
196
|
-
* still needs to see its own clarifying question on the next turn.
|
|
197
|
-
*/
|
|
198
|
-
stripQuestion?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* When true (default), strip `<think>` / `<thinking>` blocks (UI display).
|
|
201
|
-
* Set **false** for multi-turn **provider** history: MiniMax-M3 (and M2.x)
|
|
202
|
-
* require the full assistant `content` including think tags so interleaved
|
|
203
|
-
* tool-use reasoning continues. Stripping them for the API degrades tool
|
|
204
|
-
* loops ("announces intent then stops"). Display paths keep the default.
|
|
205
|
-
*/
|
|
206
|
-
stripThink?: boolean;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Strip model "private" channels from text shown to the user / re-fed as
|
|
210
|
-
* history. Covers:
|
|
211
|
-
* - complete + unclosed `<think>` / `<thinking>` (GLM/MiniMax style) — optional
|
|
212
|
-
* - MiniMax XML tool-call wrappers
|
|
213
|
-
* - clarifying-question JSON blocks (display only; keep in provider history)
|
|
214
|
-
*
|
|
215
|
-
* Without unclosed-tag stripping, streamed thinking that never got a closing
|
|
216
|
-
* tag leaked into the TUI as visible assistant prose (v1.8.1).
|
|
217
|
-
*/
|
|
218
|
-
export declare function cleanAgentContent(text: string, opts?: CleanAgentContentOptions): string;
|
|
219
|
-
/**
|
|
220
|
-
* Tools that mutate project files. In implementation-mode council runs only the
|
|
221
|
-
* chairman (Lucifero) implements; specialists + Minosse analyze and hand off.
|
|
222
|
-
* We strip these from every non-implementer so multiple agents never edit the
|
|
223
|
-
* same files (multi-writer chaos) and "who implemented" stays unambiguous.
|
|
224
|
-
* Note: specialists inherit write tools via skill `requiredTools`, so this must
|
|
225
|
-
* filter the RESULT of computeAgentTools, not just the declared role tools.
|
|
226
|
-
*/
|
|
227
|
-
export declare const MUTATING_PROJECT_TOOLS: readonly string[];
|
|
228
|
-
/**
|
|
229
|
-
* Remove file-mutating tools for non-implementer members in implementation mode.
|
|
230
|
-
* Design-phase and the implementer (chairman) keep the full set unchanged.
|
|
231
|
-
*/
|
|
232
|
-
export declare function restrictImplementationWrites(toolNames: string[], opts: {
|
|
233
|
-
runMode: CouncilRunMode;
|
|
234
|
-
isImplementer: boolean;
|
|
235
|
-
}): string[];
|
|
7
|
+
export { cleanAgentContent, hasInteractiveClarification, parseClarificationRequest, parseThinking } from './council/outputCleaning.js';
|
|
8
|
+
export type { CleanAgentContentOptions, ClarificationRequest } from './council/outputCleaning.js';
|
|
9
|
+
export { MUTATING_PROJECT_TOOLS, restrictImplementationWrites } from './council/memberMessages.js';
|
|
236
10
|
/**
|
|
237
11
|
* PURE council orchestration. Loops through specialists, optionally runs
|
|
238
12
|
* the oracle (debate mode), then runs the chairman synthesis.
|
|
@@ -244,298 +18,9 @@ export declare function restrictImplementationWrites(toolNames: string[], opts:
|
|
|
244
18
|
* Returns AsyncIterable<BrainEvent> for the full council run.
|
|
245
19
|
*/
|
|
246
20
|
export declare function runCouncilPure(userMessage: string, config: PureCouncilConfig, callbacks?: PureCouncilCallbacks): AsyncIterable<BrainEvent>;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
export
|
|
251
|
-
|
|
252
|
-
emittedToolNames: string[];
|
|
253
|
-
executableNames: ReadonlySet<string> | null;
|
|
254
|
-
sessionId: string;
|
|
255
|
-
userMessage: string;
|
|
256
|
-
agentOutputs: {
|
|
257
|
-
name: string;
|
|
258
|
-
role: string;
|
|
259
|
-
content: string;
|
|
260
|
-
}[];
|
|
261
|
-
config: PureCouncilConfig;
|
|
262
|
-
effectiveProvider: string;
|
|
263
|
-
effectiveModel: string;
|
|
264
|
-
onToolCall: () => void;
|
|
265
|
-
/** v1.7.0 (Pass-2 agy finding): pre-built language module so the retry
|
|
266
|
-
* turn's response language matches the rest of the council. Optional. */
|
|
267
|
-
languageModule?: SystemPromptModule;
|
|
268
|
-
}): AsyncGenerator<BrainEvent, void, void>;
|
|
269
|
-
/**
|
|
270
|
-
* Build the scoped fix instruction for the chairman from deterministic motion
|
|
271
|
-
* violations. Groups by file, lists file:line + rule, and constrains the model
|
|
272
|
-
* to fix ONLY these (no new features, no rewrites). Exported for testing.
|
|
273
|
-
*/
|
|
274
|
-
export declare function buildMotionFixPrompt(violations: MicroGateWarning[]): string;
|
|
275
|
-
/**
|
|
276
|
-
* Forced retry when Lucifero finished without a successful write_file/edit_file.
|
|
277
|
-
*/
|
|
278
|
-
export declare function applyImplementationWriteRetry(args: {
|
|
279
|
-
chairman: AgentRole;
|
|
280
|
-
check: {
|
|
281
|
-
ok: boolean;
|
|
282
|
-
missing: string[];
|
|
283
|
-
};
|
|
284
|
-
sessionId: string;
|
|
285
|
-
userMessage: string;
|
|
286
|
-
agentOutputs: {
|
|
287
|
-
name: string;
|
|
288
|
-
role: string;
|
|
289
|
-
content: string;
|
|
290
|
-
}[];
|
|
291
|
-
config: PureCouncilConfig;
|
|
292
|
-
effectiveProvider: string;
|
|
293
|
-
effectiveModel: string;
|
|
294
|
-
executableNames: ReadonlySet<string> | null;
|
|
295
|
-
onToolCall?: () => void;
|
|
296
|
-
onSuccessfulWrite?: () => void;
|
|
297
|
-
onCouncilStatus?: (message: string) => void;
|
|
298
|
-
/** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
|
|
299
|
-
languageModule?: SystemPromptModule;
|
|
300
|
-
}): AsyncGenerator<BrainEvent, void, void>;
|
|
301
|
-
/** Max verify-driven delivery passes after the chairman turn (inline-js, motion, etc.). */
|
|
302
|
-
export declare const MAX_DELIVERY_ATTEMPTS = 2;
|
|
303
|
-
/**
|
|
304
|
-
* Increment 5 — verify-driven delivery loop. Re-runs deterministic verification
|
|
305
|
-
* and forces scoped chairman fix turns until blocking technical issues clear
|
|
306
|
-
* or the attempt cap is hit.
|
|
307
|
-
*/
|
|
308
|
-
export declare function runChairmanDeliveryLoop(args: {
|
|
309
|
-
chairman: AgentRole;
|
|
310
|
-
projectRoot: string;
|
|
311
|
-
changedFiles: Set<string>;
|
|
312
|
-
executableNames: ReadonlySet<string> | null;
|
|
313
|
-
sessionId: string;
|
|
314
|
-
userMessage: string;
|
|
315
|
-
agentOutputs: {
|
|
316
|
-
name: string;
|
|
317
|
-
role: string;
|
|
318
|
-
content: string;
|
|
319
|
-
}[];
|
|
320
|
-
config: PureCouncilConfig;
|
|
321
|
-
effectiveProvider: string;
|
|
322
|
-
effectiveModel: string;
|
|
323
|
-
onToolCall?: () => void;
|
|
324
|
-
maxAttempts?: number;
|
|
325
|
-
onCouncilStatus?: (message: string) => void;
|
|
326
|
-
/** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
|
|
327
|
-
languageModule?: SystemPromptModule;
|
|
328
|
-
}): AsyncGenerator<BrainEvent, boolean, void>;
|
|
329
|
-
/**
|
|
330
|
-
* Re-execute edit_file/write_file calls from a `---TOOLS---` block after the
|
|
331
|
-
* chairman turn. Safety net when the harness path parsed the block but edits
|
|
332
|
-
* failed (oldString drift) or the block was not fully executed.
|
|
333
|
-
*/
|
|
334
|
-
export declare function replayChairmanTextTools(args: {
|
|
335
|
-
synthesisText: string;
|
|
336
|
-
projectRoot: string;
|
|
337
|
-
toolRegistry: ToolRegistry;
|
|
338
|
-
sessionId: string;
|
|
339
|
-
memberId?: string;
|
|
340
|
-
}): AsyncGenerator<BrainEvent, number, void>;
|
|
341
|
-
/**
|
|
342
|
-
* Increment 4 — bounded deterministic fix loop for the chairman. When the
|
|
343
|
-
* micro-gate flagged motion violations in Lucifero's writes, force a scoped
|
|
344
|
-
* fix turn (read_file + edit_file only), re-scan the changed files, and repeat
|
|
345
|
-
* until clean or the attempt cap. Emits only the fix turn's own events; the
|
|
346
|
-
* post-council verification reports the final PASS/FAIL to the user.
|
|
347
|
-
*/
|
|
348
|
-
export declare function runChairmanFixLoop(args: {
|
|
349
|
-
chairman: AgentRole;
|
|
350
|
-
violations: Map<string, MicroGateWarning>;
|
|
351
|
-
changedFiles: Set<string>;
|
|
352
|
-
projectRoot: string;
|
|
353
|
-
executableNames: ReadonlySet<string> | null;
|
|
354
|
-
sessionId: string;
|
|
355
|
-
userMessage: string;
|
|
356
|
-
agentOutputs: {
|
|
357
|
-
name: string;
|
|
358
|
-
role: string;
|
|
359
|
-
content: string;
|
|
360
|
-
}[];
|
|
361
|
-
config: PureCouncilConfig;
|
|
362
|
-
effectiveProvider: string;
|
|
363
|
-
effectiveModel: string;
|
|
364
|
-
onToolCall?: () => void;
|
|
365
|
-
maxAttempts?: number;
|
|
366
|
-
/** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
|
|
367
|
-
languageModule?: SystemPromptModule;
|
|
368
|
-
}): AsyncGenerator<BrainEvent, void, void>;
|
|
369
|
-
export interface ToolEmissionRequirement {
|
|
370
|
-
/** Tool name, e.g. 'createDocument'. */
|
|
371
|
-
name: string;
|
|
372
|
-
/** Minimum number of times this tool must have been emitted. */
|
|
373
|
-
min: number;
|
|
374
|
-
}
|
|
375
|
-
export interface ToolEmissionCheckResult {
|
|
376
|
-
/** True when every requirement is satisfied. */
|
|
377
|
-
ok: boolean;
|
|
378
|
-
/** Human-readable list of unmet requirements (empty when ok=true). */
|
|
379
|
-
missing: string[];
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Pure helper: given the list of tool names a member emitted during its
|
|
383
|
-
* turn, and a list of requirements, return whether all requirements are
|
|
384
|
-
* met.
|
|
385
|
-
*/
|
|
386
|
-
export declare function checkMemberToolEmissions(_memberId: string, emittedToolNames: string[], requirements: ToolEmissionRequirement[]): ToolEmissionCheckResult;
|
|
387
|
-
/**
|
|
388
|
-
* v0.7.8 — Per-member tool-emission requirement SETS for the design-phase
|
|
389
|
-
* council run. The outer array is an OR of alternatives: the member's turn
|
|
390
|
-
* is complete when ANY one set is fully satisfied. The FIRST set is the
|
|
391
|
-
* preferred contract — its unmet requirements drive the warning message
|
|
392
|
-
* and the forced-retry tool list.
|
|
393
|
-
*
|
|
394
|
-
* Nettuno has two ways to satisfy its contract:
|
|
395
|
-
* 1. (preferred) ONE `createPlan` batch call — phases + nested tasks +
|
|
396
|
-
* milestone in a single emission. Retry budget: 1 call, which
|
|
397
|
-
* composer-2.5 handles reliably (same shape as the Minosse/Lucifero
|
|
398
|
-
* retries that already work).
|
|
399
|
-
* 2. (legacy) the itemized trio — kept so stronger models (e.g. Opus)
|
|
400
|
-
* that emit createPhase/createTask/createMilestone directly are not
|
|
401
|
-
* flagged or retried.
|
|
402
|
-
*/
|
|
403
|
-
export declare const DESIGN_PHASE_REQUIREMENT_SETS: Record<string, ToolEmissionRequirement[][]>;
|
|
404
|
-
/**
|
|
405
|
-
* Preferred (first) requirement set per member — kept as the flat map the
|
|
406
|
-
* council loops pass to `applyRetryIfMissing` for the retry budget. For
|
|
407
|
-
* Nettuno this is `createPlan min 1`, so the forced retry advertises ONE
|
|
408
|
-
* tool with a 1-call budget instead of the old 13+-call itemized contract.
|
|
409
|
-
*/
|
|
410
|
-
export declare const DESIGN_PHASE_REQUIREMENTS: Record<string, ToolEmissionRequirement[]>;
|
|
411
|
-
/**
|
|
412
|
-
* Pure helper: OR-of-sets variant of {@link checkMemberToolEmissions}.
|
|
413
|
-
* Returns ok when ANY set is fully satisfied. When none is, the missing
|
|
414
|
-
* list reflects the FIRST (preferred) set so the warning and the retry
|
|
415
|
-
* point the model at the cheapest way to comply.
|
|
416
|
-
*/
|
|
417
|
-
export declare function checkMemberToolEmissionSets(memberId: string, emittedToolNames: string[], sets: ToolEmissionRequirement[][]): ToolEmissionCheckResult;
|
|
418
|
-
/**
|
|
419
|
-
* Run the post-condition check for a member and emit a console.warn when
|
|
420
|
-
* any required tool was not emitted the minimum number of times. Returns
|
|
421
|
-
* the check result so callers can act on it (Pass 3 may add automatic
|
|
422
|
-
* retry; for now we only warn).
|
|
423
|
-
*/
|
|
424
|
-
export declare function enforceDesignPhaseToolEmissions(memberId: string, emittedToolNames: string[]): ToolEmissionCheckResult;
|
|
425
|
-
/**
|
|
426
|
-
* Maximum number of forced retry turns per council member. Cap of 1
|
|
427
|
-
* keeps the worst-case council latency bounded (a single extra turn per
|
|
428
|
-
* member × 4 design-phase members ≈ 30-60 s on top of the base run).
|
|
429
|
-
* Going above 1 tends to produce hallucinated tool arguments because
|
|
430
|
-
* the model has already spent its "tool budget" on exploration.
|
|
431
|
-
*/
|
|
432
|
-
export declare const MAX_RETRY_PER_MEMBER = 1;
|
|
433
|
-
/**
|
|
434
|
-
* Pure helper: should the council loop spin up one more forced turn for
|
|
435
|
-
* this member to recover the missing tool emissions?
|
|
436
|
-
*
|
|
437
|
-
* Returns true when:
|
|
438
|
-
* - at least one tool is still missing after the post-condition check, AND
|
|
439
|
-
* - the retry budget for this member has not been exhausted.
|
|
440
|
-
*
|
|
441
|
-
* Returns false otherwise. Tested as a pure function so the council
|
|
442
|
-
* loop can branch on the answer without coupling to AgentHarness.
|
|
443
|
-
*/
|
|
444
|
-
export declare function shouldRetryMember(missingToolNames: string[], attemptsSoFar: number): boolean;
|
|
445
|
-
/**
|
|
446
|
-
* Build the one-line prompt that the retry turn sends to the model.
|
|
447
|
-
* The shape matters: the model is primed by its role prompt to produce
|
|
448
|
-
* prose, so the retry prompt must be unambiguous, imperative, and
|
|
449
|
-
* scoped to ONLY the missing tools.
|
|
450
|
-
*
|
|
451
|
-
* Format: "You did not emit: <names>. Call <names> NOW with concrete
|
|
452
|
-
* arguments. No prose."
|
|
453
|
-
*
|
|
454
|
-
* Multiple tools are listed comma-separated in the same call so the
|
|
455
|
-
* model can satisfy them in a single tool_calls turn (which is the
|
|
456
|
-
* cheapest path through AgentHarness).
|
|
457
|
-
*/
|
|
458
|
-
export declare function buildRetryPrompt(missingToolNames: string[]): string;
|
|
459
|
-
export declare function runRetryTurnForMember(args: {
|
|
460
|
-
agent: AgentRole;
|
|
461
|
-
missingToolNames: string[];
|
|
462
|
-
/**
|
|
463
|
-
* Per-tool minimum emission count. The retry budget is the SUM of these
|
|
464
|
-
* values (not just the number of distinct missing tools), because
|
|
465
|
-
* requirements like `createTask min: 12` need 12 separate calls even
|
|
466
|
-
* though only 1 distinct tool is missing. If omitted, the budget
|
|
467
|
-
* defaults to `missingToolNames.length` (suitable for tools like
|
|
468
|
-
* createDocument that need only one call).
|
|
469
|
-
*/
|
|
470
|
-
minPerTool?: Record<string, number>;
|
|
471
|
-
executableTools: ReadonlySet<string> | null;
|
|
472
|
-
userMessage: string;
|
|
473
|
-
ragContext: string;
|
|
474
|
-
workspaceContext: string;
|
|
475
|
-
priorOutputs: {
|
|
476
|
-
name: string;
|
|
477
|
-
role: string;
|
|
478
|
-
content: string;
|
|
479
|
-
}[];
|
|
480
|
-
aiConfig?: SystemPromptConfig;
|
|
481
|
-
sessionId: string;
|
|
482
|
-
effectiveModel: string;
|
|
483
|
-
effectiveProvider: string;
|
|
484
|
-
eventBus?: BrainEvent['sessionId'] extends string ? unknown : never;
|
|
485
|
-
toolRegistry?: unknown;
|
|
486
|
-
providerStream: ProviderStreamFn;
|
|
487
|
-
runMode?: CouncilRunMode;
|
|
488
|
-
/** Override the default buildRetryPrompt message. */
|
|
489
|
-
retryPrompt?: string;
|
|
490
|
-
/**
|
|
491
|
-
* v1.7.0 (agy audit M2): pre-built language module. Optional — when
|
|
492
|
-
* omitted, no language-policy system message is added (preserves the
|
|
493
|
-
* pre-1.7 retry behavior for tests and callers that don't track it).
|
|
494
|
-
* `runCouncilPure` threads the module it built once per run.
|
|
495
|
-
*/
|
|
496
|
-
languageModule?: SystemPromptModule;
|
|
497
|
-
}): AsyncGenerator<BrainEvent, string[], void>;
|
|
498
|
-
/**
|
|
499
|
-
* Shared retry orchestrator used by specialist, oracle, and chairman
|
|
500
|
-
* loops. Given the post-condition check result, decides whether to
|
|
501
|
-
* spin up a forced retry turn, and if so yields the events from that
|
|
502
|
-
* turn back to the caller (so the UI sees them) while mutating the
|
|
503
|
-
* shared `emittedToolNames` array (so the next post-condition check
|
|
504
|
-
* sees the union of original + retry emissions).
|
|
505
|
-
*
|
|
506
|
-
* The retry turn is skipped when:
|
|
507
|
-
* - the check passed (no missing tools), OR
|
|
508
|
-
* - the retry budget for this member is exhausted (shouldRetryMember).
|
|
509
|
-
*
|
|
510
|
-
* On retry failure (network error, model error, etc.) the function logs
|
|
511
|
-
* the error and continues — it never throws. The next post-condition
|
|
512
|
-
* check will simply re-warn.
|
|
513
|
-
*/
|
|
514
|
-
export declare function applyRetryIfMissing(args: {
|
|
515
|
-
agent: AgentRole;
|
|
516
|
-
check: ToolEmissionCheckResult;
|
|
517
|
-
/**
|
|
518
|
-
* Original per-member requirements. Used to compute the retry budget
|
|
519
|
-
* (sum of `min` for each missing tool) so the model can satisfy all
|
|
520
|
-
* minimums in one tool_calls turn. If omitted, defaults to 1 per
|
|
521
|
-
* distinct missing tool.
|
|
522
|
-
*/
|
|
523
|
-
requirements?: ToolEmissionRequirement[];
|
|
524
|
-
emittedToolNames: string[];
|
|
525
|
-
executableNames: ReadonlySet<string> | null;
|
|
526
|
-
sessionId: string;
|
|
527
|
-
userMessage: string;
|
|
528
|
-
agentOutputs: {
|
|
529
|
-
name: string;
|
|
530
|
-
role: string;
|
|
531
|
-
content: string;
|
|
532
|
-
}[];
|
|
533
|
-
config: PureCouncilConfig;
|
|
534
|
-
effectiveProvider: string;
|
|
535
|
-
effectiveModel: string;
|
|
536
|
-
/** Callback to bump the per-member tool-call counter on each retry emission. */
|
|
537
|
-
onToolCall: () => void;
|
|
538
|
-
/** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
|
|
539
|
-
languageModule?: SystemPromptModule;
|
|
540
|
-
}): AsyncGenerator<BrainEvent, void, void>;
|
|
21
|
+
export { applyCompletionRetry, applyImplementationWriteRetry, buildMotionFixPrompt, MAX_DELIVERY_ATTEMPTS, runChairmanDeliveryLoop } from './council/chairmanDelivery.js';
|
|
22
|
+
export { replayChairmanTextTools, runChairmanFixLoop } from './council/chairmanFixLoop.js';
|
|
23
|
+
export { checkMemberToolEmissionSets, checkMemberToolEmissions, DESIGN_PHASE_REQUIREMENTS, DESIGN_PHASE_REQUIREMENT_SETS, enforceDesignPhaseToolEmissions } from './council/toolEmission.js';
|
|
24
|
+
export type { ToolEmissionCheckResult, ToolEmissionRequirement } from './council/toolEmission.js';
|
|
25
|
+
export { applyRetryIfMissing, buildRetryPrompt, MAX_RETRY_PER_MEMBER, runRetryTurnForMember, shouldRetryMember } from './council/retryTurn.js';
|
|
541
26
|
//# sourceMappingURL=councilApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"councilApi.d.ts","sourceRoot":"","sources":["../../src/agents/councilApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"councilApi.d.ts","sourceRoot":"","sources":["../../src/agents/councilApi.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,qBAAqB,CAAC;AA2CtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAErG,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACvI,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAKlG,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAGnG;;;;;;;;;GASG;AACH,wBAAuB,cAAc,CACnC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,iBAAiB,EACzB,SAAS,GAAE,oBAAyB,GACnC,aAAa,CAAC,UAAU,CAAC,CAwzB3B;AAMD,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAK1K,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAK3F,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC7L,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKlG,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|