@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.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/council/chairmanDelivery.d.ts +92 -0
  3. package/dist/agents/council/chairmanDelivery.d.ts.map +1 -0
  4. package/dist/agents/council/chairmanDelivery.js +226 -0
  5. package/dist/agents/council/chairmanDelivery.js.map +1 -0
  6. package/dist/agents/council/chairmanFixLoop.d.ts +47 -0
  7. package/dist/agents/council/chairmanFixLoop.d.ts.map +1 -0
  8. package/dist/agents/council/chairmanFixLoop.js +127 -0
  9. package/dist/agents/council/chairmanFixLoop.js.map +1 -0
  10. package/dist/agents/council/memberMessages.d.ts +32 -0
  11. package/dist/agents/council/memberMessages.d.ts.map +1 -0
  12. package/dist/agents/council/memberMessages.js +95 -0
  13. package/dist/agents/council/memberMessages.js.map +1 -0
  14. package/dist/agents/council/outputCleaning.d.ts +37 -0
  15. package/dist/agents/council/outputCleaning.d.ts.map +1 -0
  16. package/dist/agents/council/outputCleaning.js +150 -0
  17. package/dist/agents/council/outputCleaning.js.map +1 -0
  18. package/dist/agents/council/retryTurn.d.ts +128 -0
  19. package/dist/agents/council/retryTurn.d.ts.map +1 -0
  20. package/dist/agents/council/retryTurn.js +200 -0
  21. package/dist/agents/council/retryTurn.js.map +1 -0
  22. package/dist/agents/council/toolEmission.d.ts +61 -0
  23. package/dist/agents/council/toolEmission.d.ts.map +1 -0
  24. package/dist/agents/council/toolEmission.js +110 -0
  25. package/dist/agents/council/toolEmission.js.map +1 -0
  26. package/dist/agents/council/types.d.ts +184 -0
  27. package/dist/agents/council/types.d.ts.map +1 -0
  28. package/dist/agents/council/types.js +15 -0
  29. package/dist/agents/council/types.js.map +1 -0
  30. package/dist/agents/councilApi.d.ts +11 -526
  31. package/dist/agents/councilApi.d.ts.map +1 -1
  32. package/dist/agents/councilApi.js +19 -893
  33. package/dist/agents/councilApi.js.map +1 -1
  34. package/dist/version.d.ts +1 -1
  35. package/dist/version.js +1 -1
  36. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Reusable runtime for [Zelari Code](https://github.com/N-THEM-Studio/zelari-code) — **Apache-2.0**.
4
4
 
5
- Current version: **2.33.0** (kept in lockstep with the `zelari-code` CLI).
5
+ Current version: **2.34.0** (kept in lockstep with the `zelari-code` CLI).
6
6
 
7
7
  ## What it is
8
8
 
@@ -0,0 +1,92 @@
1
+ /**
2
+ * chairmanDelivery — implementation-mode completion/write retries and the
3
+ * verify-driven delivery loop, extracted verbatim from agents/councilApi.ts.
4
+ */
5
+ import type { AgentRole } from '../../types/index.js';
6
+ import type { BrainEvent } from '../../shared/events.js';
7
+ import type { SystemPromptModule } from '../../types/systemTypes.js';
8
+ import { type MicroGateWarning } from '../../council/verification/microGate.js';
9
+ import type { PureCouncilConfig } from './types.js';
10
+ /**
11
+ * Implementation-mode anti-resa retry: force grep/bash after writes.
12
+ */
13
+ export declare function applyCompletionRetry(args: {
14
+ agent: AgentRole;
15
+ emittedToolNames: string[];
16
+ executableNames: ReadonlySet<string> | null;
17
+ sessionId: string;
18
+ userMessage: string;
19
+ agentOutputs: {
20
+ name: string;
21
+ role: string;
22
+ content: string;
23
+ }[];
24
+ config: PureCouncilConfig;
25
+ effectiveProvider: string;
26
+ effectiveModel: string;
27
+ onToolCall: () => void;
28
+ /** v1.7.0 (Pass-2 agy finding): pre-built language module so the retry
29
+ * turn's response language matches the rest of the council. Optional. */
30
+ languageModule?: SystemPromptModule;
31
+ }): AsyncGenerator<BrainEvent, void, void>;
32
+ /**
33
+ * Build the scoped fix instruction for the chairman from deterministic motion
34
+ * violations. Groups by file, lists file:line + rule, and constrains the model
35
+ * to fix ONLY these (no new features, no rewrites). Exported for testing.
36
+ */
37
+ export declare function buildMotionFixPrompt(violations: MicroGateWarning[]): string;
38
+ /**
39
+ * Forced retry when Lucifero finished without a successful write_file/edit_file.
40
+ */
41
+ export declare function applyImplementationWriteRetry(args: {
42
+ chairman: AgentRole;
43
+ check: {
44
+ ok: boolean;
45
+ missing: string[];
46
+ };
47
+ sessionId: string;
48
+ userMessage: string;
49
+ agentOutputs: {
50
+ name: string;
51
+ role: string;
52
+ content: string;
53
+ }[];
54
+ config: PureCouncilConfig;
55
+ effectiveProvider: string;
56
+ effectiveModel: string;
57
+ executableNames: ReadonlySet<string> | null;
58
+ onToolCall?: () => void;
59
+ onSuccessfulWrite?: () => void;
60
+ onCouncilStatus?: (message: string) => void;
61
+ /** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
62
+ languageModule?: SystemPromptModule;
63
+ }): AsyncGenerator<BrainEvent, void, void>;
64
+ /** Max verify-driven delivery passes after the chairman turn (inline-js, motion, etc.). */
65
+ export declare const MAX_DELIVERY_ATTEMPTS = 2;
66
+ /**
67
+ * Increment 5 — verify-driven delivery loop. Re-runs deterministic verification
68
+ * and forces scoped chairman fix turns until blocking technical issues clear
69
+ * or the attempt cap is hit.
70
+ */
71
+ export declare function runChairmanDeliveryLoop(args: {
72
+ chairman: AgentRole;
73
+ projectRoot: string;
74
+ changedFiles: Set<string>;
75
+ executableNames: ReadonlySet<string> | null;
76
+ sessionId: string;
77
+ userMessage: string;
78
+ agentOutputs: {
79
+ name: string;
80
+ role: string;
81
+ content: string;
82
+ }[];
83
+ config: PureCouncilConfig;
84
+ effectiveProvider: string;
85
+ effectiveModel: string;
86
+ onToolCall?: () => void;
87
+ maxAttempts?: number;
88
+ onCouncilStatus?: (message: string) => void;
89
+ /** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
90
+ languageModule?: SystemPromptModule;
91
+ }): AsyncGenerator<BrainEvent, boolean, void>;
92
+ //# sourceMappingURL=chairmanDelivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chairmanDelivery.d.ts","sourceRoot":"","sources":["../../../src/agents/council/chairmanDelivery.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OA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,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,6DAA6D;IAC7D,cAAc,CAAC,EAAE,kBAAkB,CAAC;CACrC,GAAG,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,CAuE5C"}
@@ -0,0 +1,226 @@
1
+ import { runChairmanMicroGate } from '../../council/verification/microGate.js';
2
+ import { buildImplementationVerifyRetryPrompt, checkImplementationCompletion, resolveVerifyRetryTool, } from '../../council/verification/completion.js';
3
+ import { buildDeliveryFixPrompt, buildImplementationWriteRetryPrompt, filterDeliveryBlockingFails, } from '../../council/verification/implementationDelivery.js';
4
+ import { runImplementationVerification } from '../../council/verification/runChecks.js';
5
+ import { applyInlineJsAutofix } from '../../council/verification/inlineJsAutofix.js';
6
+ import { runRetryTurnForMember, shouldRetryMember } from './retryTurn.js';
7
+ /**
8
+ * Implementation-mode anti-resa retry: force grep/bash after writes.
9
+ */
10
+ export async function* applyCompletionRetry(args) {
11
+ const check = checkImplementationCompletion(args.emittedToolNames);
12
+ if (check.ok)
13
+ return;
14
+ const retryTool = resolveVerifyRetryTool(args.executableNames);
15
+ if (!retryTool) {
16
+ // eslint-disable-next-line no-console
17
+ console.warn('[council] implementation verify retry skipped — no grep_content/bash in registry');
18
+ return;
19
+ }
20
+ if (!shouldRetryMember([retryTool], 0))
21
+ return;
22
+ // eslint-disable-next-line no-console
23
+ console.warn(`[council] ${args.agent.id} retrying missing verify tool: ${retryTool}`);
24
+ try {
25
+ const retryGenerator = runRetryTurnForMember({
26
+ agent: args.agent,
27
+ missingToolNames: [retryTool],
28
+ executableTools: args.executableNames,
29
+ userMessage: args.userMessage,
30
+ ragContext: args.config.ragContext,
31
+ workspaceContext: args.config.workspaceContext,
32
+ priorOutputs: args.agentOutputs,
33
+ aiConfig: args.config.aiConfig,
34
+ sessionId: args.sessionId,
35
+ effectiveModel: args.effectiveModel,
36
+ effectiveProvider: args.effectiveProvider,
37
+ eventBus: args.config.eventBus,
38
+ toolRegistry: args.config.tools,
39
+ providerStream: args.config.providerStream,
40
+ runMode: args.config.runMode,
41
+ retryPrompt: buildImplementationVerifyRetryPrompt(retryTool),
42
+ languageModule: args.languageModule,
43
+ });
44
+ for await (const event of retryGenerator) {
45
+ if (event.type === 'tool_execution_start') {
46
+ args.onToolCall();
47
+ args.emittedToolNames.push(event.toolName);
48
+ }
49
+ yield event;
50
+ }
51
+ }
52
+ catch (retryErr) {
53
+ // eslint-disable-next-line no-console
54
+ console.error(`[council] ${args.agent.id} verify retry failed:`, retryErr);
55
+ }
56
+ const after = checkImplementationCompletion(args.emittedToolNames);
57
+ if (!after.ok) {
58
+ // eslint-disable-next-line no-console
59
+ console.warn(`[council] ${args.agent.id} still missing verify after retry: ${after.reason}`);
60
+ }
61
+ }
62
+ /**
63
+ * Build the scoped fix instruction for the chairman from deterministic motion
64
+ * violations. Groups by file, lists file:line + rule, and constrains the model
65
+ * to fix ONLY these (no new features, no rewrites). Exported for testing.
66
+ */
67
+ export function buildMotionFixPrompt(violations) {
68
+ const byFile = new Map();
69
+ for (const v of violations) {
70
+ const file = v.file || 'index.html';
71
+ const loc = v.line ? `${file}:L${v.line}` : file;
72
+ const list = byFile.get(file) ?? [];
73
+ list.push(` - ${loc}: ${v.message}`);
74
+ byFile.set(file, list);
75
+ }
76
+ const blocks = Array.from(byFile.values()).map((lines) => lines.join('\n')).join('\n');
77
+ return (`Deterministic verification found ${violations.length} motion violation(s) in the file(s) you just edited. ` +
78
+ `Fix ONLY these — do not add features, do not rewrite sections, do not touch anything else:\n${blocks}\n\n` +
79
+ `Rules: animate ONLY transform and opacity. Replace any box-shadow / background / background-position / ` +
80
+ `filter / color / border-color / width / height / grid-template-rows used in @keyframes or transitions with ` +
81
+ `transform/opacity equivalents (e.g. render a glow via a pseudo-element that scales and fades). For every ` +
82
+ `classList.add('x') in the script, add a matching '.x' CSS rule. Use read_file to see the exact lines, then ` +
83
+ `edit_file. When the listed items are fixed, stop — no summary.`);
84
+ }
85
+ /**
86
+ * Forced retry when Lucifero finished without a successful write_file/edit_file.
87
+ */
88
+ export async function* applyImplementationWriteRetry(args) {
89
+ if (args.check.ok)
90
+ return;
91
+ if (!shouldRetryMember(['write_file'], 0))
92
+ return;
93
+ const statusMsg = `[council] ${args.chairman.id} implementation write retry: ${args.check.missing.join(', ')}`;
94
+ args.onCouncilStatus?.(statusMsg);
95
+ // eslint-disable-next-line no-console
96
+ console.warn(statusMsg);
97
+ try {
98
+ const retryGenerator = runRetryTurnForMember({
99
+ agent: args.chairman,
100
+ missingToolNames: ['read_file', 'write_file', 'edit_file'],
101
+ minPerTool: { read_file: 3, edit_file: 8, write_file: 1 },
102
+ executableTools: args.executableNames,
103
+ userMessage: args.userMessage,
104
+ ragContext: args.config.ragContext,
105
+ workspaceContext: args.config.workspaceContext,
106
+ priorOutputs: args.agentOutputs,
107
+ aiConfig: args.config.aiConfig,
108
+ sessionId: args.sessionId,
109
+ effectiveModel: args.effectiveModel,
110
+ effectiveProvider: args.effectiveProvider,
111
+ eventBus: args.config.eventBus,
112
+ toolRegistry: args.config.tools,
113
+ providerStream: args.config.providerStream,
114
+ runMode: 'implementation',
115
+ retryPrompt: buildImplementationWriteRetryPrompt(args.userMessage),
116
+ languageModule: args.languageModule,
117
+ });
118
+ for await (const event of retryGenerator) {
119
+ if (event.type === 'tool_execution_start')
120
+ args.onToolCall?.();
121
+ if (event.type === 'tool_execution_end' &&
122
+ !event.isError &&
123
+ typeof event.result === 'string') {
124
+ try {
125
+ const parsed = JSON.parse(event.result);
126
+ if ((parsed.bytesWritten ?? 0) > 0 ||
127
+ (parsed.occurrencesReplaced ?? 0) > 0) {
128
+ args.onSuccessfulWrite?.();
129
+ }
130
+ }
131
+ catch {
132
+ if (event.result.includes('bytesWritten') || event.result.includes('occurrencesReplaced')) {
133
+ args.onSuccessfulWrite?.();
134
+ }
135
+ }
136
+ }
137
+ yield event;
138
+ }
139
+ }
140
+ catch (retryErr) {
141
+ // eslint-disable-next-line no-console
142
+ console.error(`[council] ${args.chairman.id} implementation write retry failed:`, retryErr);
143
+ }
144
+ }
145
+ /** Max verify-driven delivery passes after the chairman turn (inline-js, motion, etc.). */
146
+ export const MAX_DELIVERY_ATTEMPTS = 2;
147
+ /**
148
+ * Increment 5 — verify-driven delivery loop. Re-runs deterministic verification
149
+ * and forces scoped chairman fix turns until blocking technical issues clear
150
+ * or the attempt cap is hit.
151
+ */
152
+ export async function* runChairmanDeliveryLoop(args) {
153
+ const maxAttempts = args.maxAttempts ?? MAX_DELIVERY_ATTEMPTS;
154
+ const zelariRoot = `${args.projectRoot}/.zelari`;
155
+ let attempt = 0;
156
+ while (attempt < maxAttempts) {
157
+ const report = runImplementationVerification({
158
+ projectRoot: args.projectRoot,
159
+ zelariRoot,
160
+ });
161
+ const blocking = filterDeliveryBlockingFails(report.results);
162
+ if (blocking.length === 0)
163
+ return true;
164
+ if (blocking.some((b) => b.id === 'inline-js.budget')) {
165
+ const jsFix = applyInlineJsAutofix(args.projectRoot, report);
166
+ if (jsFix.applied) {
167
+ args.onCouncilStatus?.(`[council] ${args.chairman.id} inline-js autofix: ${jsFix.fixes.join('; ')}`);
168
+ const afterJs = runImplementationVerification({
169
+ projectRoot: args.projectRoot,
170
+ zelariRoot,
171
+ });
172
+ if (filterDeliveryBlockingFails(afterJs.results).length === 0)
173
+ return true;
174
+ }
175
+ }
176
+ attempt++;
177
+ const statusMsg = `[council] ${args.chairman.id} delivery pass ${attempt}/${maxAttempts}: ${blocking.map((b) => b.id).join(', ')}`;
178
+ args.onCouncilStatus?.(statusMsg);
179
+ // eslint-disable-next-line no-console
180
+ console.warn(statusMsg);
181
+ try {
182
+ const fixGenerator = runRetryTurnForMember({
183
+ agent: args.chairman,
184
+ missingToolNames: ['read_file', 'edit_file'],
185
+ minPerTool: { read_file: 3, edit_file: 10 },
186
+ executableTools: args.executableNames,
187
+ userMessage: args.userMessage,
188
+ ragContext: args.config.ragContext,
189
+ workspaceContext: args.config.workspaceContext,
190
+ priorOutputs: args.agentOutputs,
191
+ aiConfig: args.config.aiConfig,
192
+ sessionId: args.sessionId,
193
+ effectiveModel: args.effectiveModel,
194
+ effectiveProvider: args.effectiveProvider,
195
+ eventBus: args.config.eventBus,
196
+ toolRegistry: args.config.tools,
197
+ providerStream: args.config.providerStream,
198
+ runMode: 'implementation',
199
+ retryPrompt: buildDeliveryFixPrompt(blocking, args.userMessage),
200
+ languageModule: args.languageModule,
201
+ });
202
+ for await (const event of fixGenerator) {
203
+ if (event.type === 'tool_execution_start')
204
+ args.onToolCall?.();
205
+ yield event;
206
+ }
207
+ }
208
+ catch (deliveryErr) {
209
+ // eslint-disable-next-line no-console
210
+ console.error(`[council] ${args.chairman.id} delivery pass ${attempt} failed:`, deliveryErr);
211
+ break;
212
+ }
213
+ for (const rel of args.changedFiles) {
214
+ for (const w of runChairmanMicroGate({ projectRoot: args.projectRoot, relPath: rel, zelariRoot })) {
215
+ // refresh changed set — delivery may touch same targets
216
+ args.changedFiles.add(w.file ?? rel);
217
+ }
218
+ }
219
+ }
220
+ const finalReport = runImplementationVerification({
221
+ projectRoot: args.projectRoot,
222
+ zelariRoot,
223
+ });
224
+ return filterDeliveryBlockingFails(finalReport.results).length === 0;
225
+ }
226
+ //# sourceMappingURL=chairmanDelivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chairmanDelivery.js","sourceRoot":"","sources":["../../../src/agents/council/chairmanDelivery.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yCAAyC,CAAC;AACtG,OAAO,EACP,oCAAoC,EACpC,6BAA6B,EAC7B,sBAAsB,GACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACP,sBAAsB,EACtB,mCAAmC,EACnC,2BAA2B,GAC1B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAE,qBAAqB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CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,WAAW,GAAG,6BAA6B,CAAC;QAChD,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU;KACX,CAAC,CAAC;IACH,OAAO,2BAA2B,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { AgentRole } from '../../types/index.js';
2
+ import type { BrainEvent } from '../../shared/events.js';
3
+ import type { SystemPromptModule } from '../../types/systemTypes.js';
4
+ import { ToolRegistry } from '../../core/tools/registry.js';
5
+ import { type MicroGateWarning } from '../../council/verification/microGate.js';
6
+ import type { PureCouncilConfig } from './types.js';
7
+ /**
8
+ * Re-execute edit_file/write_file calls from a `---TOOLS---` block after the
9
+ * chairman turn. Safety net when the harness path parsed the block but edits
10
+ * failed (oldString drift) or the block was not fully executed.
11
+ */
12
+ export declare function replayChairmanTextTools(args: {
13
+ synthesisText: string;
14
+ projectRoot: string;
15
+ toolRegistry: ToolRegistry;
16
+ sessionId: string;
17
+ memberId?: string;
18
+ }): AsyncGenerator<BrainEvent, number, void>;
19
+ /**
20
+ * Increment 4 — bounded deterministic fix loop for the chairman. When the
21
+ * micro-gate flagged motion violations in Lucifero's writes, force a scoped
22
+ * fix turn (read_file + edit_file only), re-scan the changed files, and repeat
23
+ * until clean or the attempt cap. Emits only the fix turn's own events; the
24
+ * post-council verification reports the final PASS/FAIL to the user.
25
+ */
26
+ export declare function runChairmanFixLoop(args: {
27
+ chairman: AgentRole;
28
+ violations: Map<string, MicroGateWarning>;
29
+ changedFiles: Set<string>;
30
+ projectRoot: string;
31
+ executableNames: ReadonlySet<string> | null;
32
+ sessionId: string;
33
+ userMessage: string;
34
+ agentOutputs: {
35
+ name: string;
36
+ role: string;
37
+ content: string;
38
+ }[];
39
+ config: PureCouncilConfig;
40
+ effectiveProvider: string;
41
+ effectiveModel: string;
42
+ onToolCall?: () => void;
43
+ maxAttempts?: number;
44
+ /** v1.7.0 (Pass-2 agy finding): see applyCompletionRetry. */
45
+ languageModule?: SystemPromptModule;
46
+ }): AsyncGenerator<BrainEvent, void, void>;
47
+ //# sourceMappingURL=chairmanFixLoop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chairmanFixLoop.d.ts","sourceRoot":"","sources":["../../../src/agents/council/chairmanFixLoop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAGtG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;GAIG;AACH,wBAAuB,uBAAuB,CAAC,IAAI,EAAE;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAkD3C;AAED;;;;;;GAMG;AACH,wBAAuB,kBAAkB,CAAC,IAAI,EAAE;IAC9C,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,kBAAkB,CAAC;CACrC,GAAG,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CA8CzC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * chairmanFixLoop — ---TOOLS--- replay and the bounded micro-gate fix loop,
3
+ * extracted verbatim from agents/councilApi.ts.
4
+ */
5
+ import { normalizeTextToolArgs, parseTextToolCalls } from '../../core/AgentHarness.js';
6
+ import { createBrainEvent } from '../../shared/events.js';
7
+ import { runChairmanMicroGate } from '../../council/verification/microGate.js';
8
+ import { buildMotionFixPrompt } from './chairmanDelivery.js';
9
+ import { runRetryTurnForMember } from './retryTurn.js';
10
+ /**
11
+ * Re-execute edit_file/write_file calls from a `---TOOLS---` block after the
12
+ * chairman turn. Safety net when the harness path parsed the block but edits
13
+ * failed (oldString drift) or the block was not fully executed.
14
+ */
15
+ export async function* replayChairmanTextTools(args) {
16
+ const tools = parseTextToolCalls(args.synthesisText);
17
+ if (tools.length === 0)
18
+ return 0;
19
+ let applied = 0;
20
+ for (const tt of tools) {
21
+ if (tt.name !== 'edit_file' && tt.name !== 'write_file')
22
+ continue;
23
+ const normalized = normalizeTextToolArgs(tt.name, tt.args);
24
+ const toolCallId = `replay-${crypto.randomUUID().slice(0, 8)}`;
25
+ yield createBrainEvent('tool_execution_start', args.sessionId, {
26
+ toolCallId,
27
+ toolName: tt.name,
28
+ args: normalized,
29
+ ...(args.memberId ? { memberId: args.memberId } : {}),
30
+ });
31
+ const startMs = Date.now();
32
+ let resultStr = '';
33
+ let isError = false;
34
+ try {
35
+ const result = await args.toolRegistry.invoke(tt.name, normalized, {
36
+ cwd: args.projectRoot,
37
+ sessionId: args.sessionId,
38
+ });
39
+ if (result.ok) {
40
+ const val = result.value;
41
+ if (tt.name === 'edit_file' && val.occurrencesReplaced === 0) {
42
+ resultStr = `edit_file: no match for oldString (replay)`;
43
+ isError = true;
44
+ }
45
+ else {
46
+ resultStr =
47
+ typeof result.value === 'string'
48
+ ? result.value
49
+ : JSON.stringify(result.value, null, 2);
50
+ applied += 1;
51
+ }
52
+ }
53
+ else {
54
+ resultStr = result.error;
55
+ isError = true;
56
+ }
57
+ }
58
+ catch (err) {
59
+ resultStr = err instanceof Error ? err.message : String(err);
60
+ isError = true;
61
+ }
62
+ yield createBrainEvent('tool_execution_end', args.sessionId, {
63
+ toolCallId,
64
+ result: resultStr,
65
+ isError,
66
+ durationMs: Date.now() - startMs,
67
+ });
68
+ }
69
+ return applied;
70
+ }
71
+ /**
72
+ * Increment 4 — bounded deterministic fix loop for the chairman. When the
73
+ * micro-gate flagged motion violations in Lucifero's writes, force a scoped
74
+ * fix turn (read_file + edit_file only), re-scan the changed files, and repeat
75
+ * until clean or the attempt cap. Emits only the fix turn's own events; the
76
+ * post-council verification reports the final PASS/FAIL to the user.
77
+ */
78
+ export async function* runChairmanFixLoop(args) {
79
+ const maxAttempts = args.maxAttempts ?? 3;
80
+ const zelariRoot = `${args.projectRoot}/.zelari`;
81
+ let current = Array.from(args.violations.values());
82
+ let attempt = 0;
83
+ while (current.length > 0 && attempt < maxAttempts) {
84
+ attempt++;
85
+ try {
86
+ const fixGenerator = runRetryTurnForMember({
87
+ agent: args.chairman,
88
+ missingToolNames: ['read_file', 'edit_file'],
89
+ minPerTool: { read_file: 2, edit_file: 8 },
90
+ executableTools: args.executableNames,
91
+ userMessage: args.userMessage,
92
+ ragContext: args.config.ragContext,
93
+ workspaceContext: args.config.workspaceContext,
94
+ priorOutputs: args.agentOutputs,
95
+ aiConfig: args.config.aiConfig,
96
+ sessionId: args.sessionId,
97
+ effectiveModel: args.effectiveModel,
98
+ effectiveProvider: args.effectiveProvider,
99
+ eventBus: args.config.eventBus,
100
+ toolRegistry: args.config.tools,
101
+ providerStream: args.config.providerStream,
102
+ runMode: 'implementation',
103
+ retryPrompt: buildMotionFixPrompt(current),
104
+ languageModule: args.languageModule,
105
+ });
106
+ for await (const event of fixGenerator) {
107
+ if (event.type === 'tool_execution_start')
108
+ args.onToolCall?.();
109
+ yield event;
110
+ }
111
+ }
112
+ catch (fixErr) {
113
+ // eslint-disable-next-line no-console
114
+ console.error(`[council] chairman fix pass ${attempt} failed:`, fixErr);
115
+ break;
116
+ }
117
+ // Re-scan the changed target files for the next iteration / termination.
118
+ const rescanned = new Map();
119
+ for (const relPath of args.changedFiles) {
120
+ for (const w of runChairmanMicroGate({ projectRoot: args.projectRoot, relPath, zelariRoot })) {
121
+ rescanned.set(`${w.id}|${w.file}|${w.line ?? ''}`, w);
122
+ }
123
+ }
124
+ current = Array.from(rescanned.values());
125
+ }
126
+ }
127
+ //# sourceMappingURL=chairmanFixLoop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chairmanFixLoop.js","sourceRoot":"","sources":["../../../src/agents/council/chairmanFixLoop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yCAAyC,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGvD;;;;GAIG;AACH,MAAM,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UAAU,EAAE,EAAE,CAAC;gBAC/D,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,+BAA+B,OAAO,UAAU,EAAE,MAAM,CAAC,CAAC;YACxE,MAAM;QACR,CAAC;QACD,yEAAyE;QACzE,MAAM,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAC;QACtD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACxC,KAAK,MAAM,CAAC,IAAI,oBAAoB,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;gBAC7F,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * memberMessages — per-member system/user message construction, extracted
3
+ * verbatim from agents/councilApi.ts.
4
+ */
5
+ import type { AgentRole } from '../../types/index.js';
6
+ import type { AgentMessage } from '../../core/AgentHarness.js';
7
+ import type { SystemPromptConfig, SystemPromptModule } from '../../types/systemTypes.js';
8
+ import type { CouncilRunMode } from '../../council/runMode.js';
9
+ /**
10
+ * Tools that mutate project files. In implementation-mode council runs only the
11
+ * chairman (Lucifero) implements; specialists + Minosse analyze and hand off.
12
+ * We strip these from every non-implementer so multiple agents never edit the
13
+ * same files (multi-writer chaos) and "who implemented" stays unambiguous.
14
+ * Note: specialists inherit write tools via skill `requiredTools`, so this must
15
+ * filter the RESULT of computeAgentTools, not just the declared role tools.
16
+ */
17
+ export declare const MUTATING_PROJECT_TOOLS: readonly string[];
18
+ /**
19
+ * Remove file-mutating tools for non-implementer members in implementation mode.
20
+ * Design-phase and the implementer (chairman) keep the full set unchanged.
21
+ */
22
+ export declare function restrictImplementationWrites(toolNames: string[], opts: {
23
+ runMode: CouncilRunMode;
24
+ isImplementer: boolean;
25
+ }): string[];
26
+ /** @internal */
27
+ export declare function buildAgentMessages(agent: AgentRole, userMessage: string, ragContext: string, workspaceContext: string, priorOutputs: {
28
+ name: string;
29
+ role: string;
30
+ content: string;
31
+ }[], aiConfig?: SystemPromptConfig, executableTools?: ReadonlySet<string> | null, runMode?: CouncilRunMode, languageModule?: SystemPromptModule): AgentMessage[];
32
+ //# sourceMappingURL=memberMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memberMessages.d.ts","sourceRoot":"","sources":["../../../src/agents/council/memberMessages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM/D;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAAgC,CAAC;AAErF;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EAAE,EACnB,IAAI,EAAE;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GACxD,MAAM,EAAE,CAGV;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,EAC/D,QAAQ,CAAC,EAAE,kBAAkB,EAC7B,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,EAC5C,OAAO,GAAE,cAAiC,EAC1C,cAAc,CAAC,EAAE,kBAAkB,GAClC,YAAY,EAAE,CA6EhB"}