specrails-core 5.4.0 → 5.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +2 -0
  2. package/dist/agent-runtime/capabilities.d.ts +3 -2
  3. package/dist/agent-runtime/capabilities.js +10 -2
  4. package/dist/agent-runtime/capabilities.js.map +1 -1
  5. package/dist/agent-runtime/cli-executor.js +10 -5
  6. package/dist/agent-runtime/cli-executor.js.map +1 -1
  7. package/dist/agent-runtime/cli-process.d.ts +1 -0
  8. package/dist/agent-runtime/cli-process.js +13 -2
  9. package/dist/agent-runtime/cli-process.js.map +1 -1
  10. package/dist/agent-runtime/cli.js +2 -1
  11. package/dist/agent-runtime/cli.js.map +1 -1
  12. package/dist/agent-runtime/compact/architect.d.ts +349 -0
  13. package/dist/agent-runtime/compact/architect.js +371 -0
  14. package/dist/agent-runtime/compact/architect.js.map +1 -0
  15. package/dist/agent-runtime/compact/chat-client.d.ts +83 -0
  16. package/dist/agent-runtime/compact/chat-client.js +307 -0
  17. package/dist/agent-runtime/compact/chat-client.js.map +1 -0
  18. package/dist/agent-runtime/compact/developer.d.ts +160 -0
  19. package/dist/agent-runtime/compact/developer.js +823 -0
  20. package/dist/agent-runtime/compact/developer.js.map +1 -0
  21. package/dist/agent-runtime/compact/environment.d.ts +62 -0
  22. package/dist/agent-runtime/compact/environment.js +213 -0
  23. package/dist/agent-runtime/compact/environment.js.map +1 -0
  24. package/dist/agent-runtime/compact/exit-code-honesty.d.ts +8 -0
  25. package/dist/agent-runtime/compact/exit-code-honesty.js +78 -0
  26. package/dist/agent-runtime/compact/exit-code-honesty.js.map +1 -0
  27. package/dist/agent-runtime/compact/guarded-loop.d.ts +73 -0
  28. package/dist/agent-runtime/compact/guarded-loop.js +320 -0
  29. package/dist/agent-runtime/compact/guarded-loop.js.map +1 -0
  30. package/dist/agent-runtime/compact/prompt-inputs.d.ts +42 -0
  31. package/dist/agent-runtime/compact/prompt-inputs.js +59 -0
  32. package/dist/agent-runtime/compact/prompt-inputs.js.map +1 -0
  33. package/dist/agent-runtime/compact/reviewer.d.ts +24 -0
  34. package/dist/agent-runtime/compact/reviewer.js +178 -0
  35. package/dist/agent-runtime/compact/reviewer.js.map +1 -0
  36. package/dist/agent-runtime/compact/step.d.ts +70 -0
  37. package/dist/agent-runtime/compact/step.js +136 -0
  38. package/dist/agent-runtime/compact/step.js.map +1 -0
  39. package/dist/agent-runtime/compact/test-reachability.d.ts +30 -0
  40. package/dist/agent-runtime/compact/test-reachability.js +147 -0
  41. package/dist/agent-runtime/compact/test-reachability.js.map +1 -0
  42. package/dist/agent-runtime/config.js +40 -10
  43. package/dist/agent-runtime/config.js.map +1 -1
  44. package/dist/agent-runtime/core-host.d.ts +4 -4
  45. package/dist/agent-runtime/core-host.js +8 -3
  46. package/dist/agent-runtime/core-host.js.map +1 -1
  47. package/dist/agent-runtime/executor-types.d.ts +37 -3
  48. package/dist/agent-runtime/executor-types.js +7 -2
  49. package/dist/agent-runtime/executor-types.js.map +1 -1
  50. package/dist/agent-runtime/graph/nodes.d.ts +4 -2
  51. package/dist/agent-runtime/graph/nodes.js +160 -53
  52. package/dist/agent-runtime/graph/nodes.js.map +1 -1
  53. package/dist/agent-runtime/graph/roles.d.ts +7 -2
  54. package/dist/agent-runtime/graph/roles.js +19 -11
  55. package/dist/agent-runtime/graph/roles.js.map +1 -1
  56. package/dist/agent-runtime/graph/state.d.ts +2 -1
  57. package/dist/agent-runtime/graph/state.js +2 -1
  58. package/dist/agent-runtime/graph/state.js.map +1 -1
  59. package/dist/agent-runtime/guardrails.d.ts +15 -0
  60. package/dist/agent-runtime/guardrails.js +76 -0
  61. package/dist/agent-runtime/guardrails.js.map +1 -0
  62. package/dist/agent-runtime/openai-executor.d.ts +25 -1
  63. package/dist/agent-runtime/openai-executor.js +67 -122
  64. package/dist/agent-runtime/openai-executor.js.map +1 -1
  65. package/dist/agent-runtime/openspec-tool-server.js +3 -3
  66. package/dist/agent-runtime/openspec-tool-server.js.map +1 -1
  67. package/dist/agent-runtime/openspec.d.ts +76 -1
  68. package/dist/agent-runtime/openspec.js +70 -4
  69. package/dist/agent-runtime/openspec.js.map +1 -1
  70. package/dist/agent-runtime/prompts.d.ts +21 -2
  71. package/dist/agent-runtime/prompts.js +56 -6
  72. package/dist/agent-runtime/prompts.js.map +1 -1
  73. package/dist/agent-runtime/repository-context.js +39 -12
  74. package/dist/agent-runtime/repository-context.js.map +1 -1
  75. package/dist/agent-runtime/role-routing.js +1 -0
  76. package/dist/agent-runtime/role-routing.js.map +1 -1
  77. package/dist/agent-runtime/workflow-types.d.ts +2 -0
  78. package/dist/agent-runtime/workflow.js +1 -1
  79. package/dist/agent-runtime/workflow.js.map +1 -1
  80. package/dist/installer/runtime/pipeline-state.d.ts +1 -0
  81. package/dist/installer/runtime/pipeline-state.js +35 -4
  82. package/dist/installer/runtime/pipeline-state.js.map +1 -1
  83. package/docs/agent-runtime.md +8 -0
  84. package/docs/ci-cd.md +6 -3
  85. package/package.json +2 -2
  86. package/schemas/agent-runtime.schema.json +10 -2
@@ -0,0 +1,307 @@
1
+ import { AgentExecutionError } from '../executor-types.js';
2
+ import { sumCacheUsage } from '../efficiency-types.js';
3
+ /**
4
+ * Node's fetch (undici) aborts a request whose headers take > 5 min or whose
5
+ * body stalls > 5 min (`UND_ERR_HEADERS_TIMEOUT` / `UND_ERR_BODY_TIMEOUT`).
6
+ * A local model reasoning for minutes before its first token trips both.
7
+ * The step's own AbortSignal is the real deadline, so the compact client
8
+ * dispatches through an undici Agent with those timers off. Built from the
9
+ * global dispatcher's constructor (no dependency); absent ⇒ default fetch.
10
+ */
11
+ let patientDispatcher;
12
+ function resolvePatientDispatcher() {
13
+ try {
14
+ const symbol = Object.getOwnPropertySymbols(globalThis).find(item => String(item).includes('undici.globalDispatcher'));
15
+ const current = symbol ? globalThis[symbol] : undefined;
16
+ const Agent = current && typeof current === 'object' ? current.constructor : undefined;
17
+ if (Agent)
18
+ patientDispatcher = new Agent({ headersTimeout: 0, bodyTimeout: 0, connectTimeout: 30_000 });
19
+ }
20
+ catch { /* default fetch below */ }
21
+ }
22
+ /**
23
+ * Node creates its global undici dispatcher LAZILY, on the first fetch — so
24
+ * a fresh runtime process had no symbol to read, `patientDispatcher` stayed
25
+ * null and every request ran with undici's default 300 s body timeout
26
+ * (observed: `UND_ERR_BODY_TIMEOUT` killing a run whose Mac-mini model spent
27
+ * >5 min on one prefill/generation with no bytes on the wire). Force the
28
+ * lazy init with one refused loopback connect, then read the constructor.
29
+ */
30
+ export async function ensurePatientDispatcher() {
31
+ if (patientDispatcher !== undefined)
32
+ return;
33
+ patientDispatcher = null;
34
+ resolvePatientDispatcher();
35
+ if (patientDispatcher)
36
+ return;
37
+ try {
38
+ await globalThis.fetch('http://127.0.0.1:9/', { method: 'HEAD', signal: AbortSignal.timeout(2000) });
39
+ }
40
+ catch { /* the refused connect is the point */ }
41
+ resolvePatientDispatcher();
42
+ }
43
+ export function patientFetchInit() {
44
+ if (patientDispatcher === undefined) {
45
+ patientDispatcher = null;
46
+ resolvePatientDispatcher();
47
+ }
48
+ return patientDispatcher ? { dispatcher: patientDispatcher } : {};
49
+ }
50
+ const RETRY_DELAY_MS = 3000;
51
+ function sleep(ms, signal) {
52
+ return new Promise((resolve, reject) => { const timer = setTimeout(resolve, ms); signal.addEventListener('abort', () => { clearTimeout(timer); reject(signal.reason); }, { once: true }); });
53
+ }
54
+ export function record(value) {
55
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
56
+ }
57
+ function number(value) { return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null; }
58
+ function add(left, right) { return left === null || right === null ? null : left + right; }
59
+ /**
60
+ * One non-streaming `chat/completions` round trip with the executor's usage
61
+ * accounting: every response adds to the running totals, emits a usage event and
62
+ * is checked against the token/cost budget before the caller sees the message.
63
+ */
64
+ export class ChatClient {
65
+ options;
66
+ usage = { inputTokens: 0, outputTokens: 0, costUsd: 0 };
67
+ responses = 0;
68
+ /** Endpoints without `response_format` support are remembered after the first rejection. */
69
+ structuredOutput = 'unknown';
70
+ /** Effort is sent while the endpoint accepts it; a per-model rejection turns it off for the session. */
71
+ effortEnabled;
72
+ thinkingOff;
73
+ constructor(options) {
74
+ this.options = options;
75
+ this.effortEnabled = options.effortSupported === true;
76
+ this.thinkingOff = options.thinking === 'off';
77
+ }
78
+ /** The effort every call carries unless a per-call control overrides it (undefined when the endpoint declared no support). */
79
+ get defaultEffort() { return this.effortEnabled ? this.options.reasoningEffort : undefined; }
80
+ get budgetUsage() { return this.responses ? this.usage : { inputTokens: null, outputTokens: null, costUsd: null }; }
81
+ /** Per-call generation controls. `reasoningEffort` is sent only when the
82
+ * endpoint declared support; `temperature`/`max_tokens` are universal. */
83
+ async complete(body, controls = {}) {
84
+ const { options } = this;
85
+ const effort = controls.reasoningEffort ?? options.reasoningEffort;
86
+ options.signal.throwIfAborted();
87
+ const observed = (this.usage.inputTokens ?? 0) + (this.usage.outputTokens ?? 0);
88
+ if (options.maxTokens !== undefined && this.responses && (this.usage.inputTokens === null || this.usage.outputTokens === null))
89
+ throw new AgentExecutionError('Provider omitted usage required by the token budget', 'usage_unavailable', this.usage);
90
+ if (options.maxTokens !== undefined && observed >= options.maxTokens)
91
+ throw new AgentExecutionError('Agent token budget exhausted', 'token_budget', this.usage);
92
+ // Local servers hiccup (5xx / connection reset) under long sessions; one
93
+ // bounded retry keeps a 30-minute run from dying on a transient error.
94
+ if (options.fetch === globalThis.fetch)
95
+ await ensurePatientDispatcher();
96
+ const send = () => options.fetch(options.endpoint, {
97
+ method: 'POST', headers: options.headers, signal: options.signal, redirect: 'error', ...(options.fetch === globalThis.fetch ? patientFetchInit() : {}),
98
+ body: JSON.stringify({ model: options.model, ...body, stream: true, stream_options: { include_usage: true },
99
+ ...(controls.temperature === undefined ? {} : { temperature: controls.temperature }),
100
+ ...(this.effortEnabled && effort ? { reasoning_effort: effort } : {}),
101
+ ...(this.thinkingOff ? { chat_template_kwargs: { enable_thinking: false } } : {}),
102
+ ...(options.maxTokens === undefined
103
+ ? (controls.maxOutputTokens === undefined ? {} : { max_tokens: controls.maxOutputTokens })
104
+ : { max_tokens: Math.max(1, Math.floor(Math.min(options.maxTokens - observed, controls.maxOutputTokens ?? Infinity))) }),
105
+ }),
106
+ });
107
+ let response = await send().catch(async (error) => { await sleep(RETRY_DELAY_MS, options.signal); return send().catch(() => { throw error; }); });
108
+ if (!response.ok && response.status >= 500) {
109
+ await response.body?.cancel();
110
+ await sleep(RETRY_DELAY_MS, options.signal);
111
+ response = await send();
112
+ }
113
+ // A model that cannot reason rejects `reasoning_effort` (Ollama: 400
114
+ // "does not support thinking"). Drop the field for the rest of the
115
+ // session and resend once — the connection's declaration was too broad
116
+ // for this particular model, which is not a reason to fail the step.
117
+ // Likewise an endpoint that does not know `chat_template_kwargs` (a non-Qwen
118
+ // template, an older server): drop the switch for the session and resend.
119
+ if (response.status === 400 && this.thinkingOff) {
120
+ const text = await response.text().catch(() => '');
121
+ if (/chat_template_kwargs|enable_thinking|unknown field|unrecognized|extra_forbidden|not permitted/i.test(text)) {
122
+ this.thinkingOff = false;
123
+ options.onEvent?.({ kind: 'text', text: `The endpoint rejected the thinking switch (chat_template_kwargs) for ${options.model}; continuing with the server default.` });
124
+ response = await send();
125
+ }
126
+ else {
127
+ response = new Response(text, { status: 400, headers: response.headers });
128
+ }
129
+ }
130
+ if (response.status === 400 && this.effortEnabled && effort) {
131
+ const text = await response.text().catch(() => '');
132
+ if (/does not support thinking|reasoning_effort|unknown field.*reasoning/i.test(text)) {
133
+ this.effortEnabled = false;
134
+ options.onEvent?.({ kind: 'text', text: `The endpoint rejected reasoning_effort for ${options.model}; continuing without it.` });
135
+ response = await send();
136
+ }
137
+ else {
138
+ response = new Response(text, { status: 400, headers: response.headers });
139
+ }
140
+ }
141
+ if (!response.ok) {
142
+ await response.body?.cancel();
143
+ throw new AgentExecutionError(`OpenAI-compatible provider returned HTTP ${response.status}`, 'provider_http_error', this.budgetUsage);
144
+ }
145
+ const data = record(await readCompletionResponse(response)), reported = record(data?.usage);
146
+ const cached = number(record(reported?.prompt_tokens_details)?.cached_tokens);
147
+ const inputTokens = number(reported?.prompt_tokens);
148
+ const cache = record(reported?.prompt_tokens_details)?.cached_tokens === undefined ? {} : {
149
+ cacheReadInputTokens: cached !== null && inputTokens !== null && cached <= inputTokens ? cached : null,
150
+ uncachedInputTokens: cached !== null && inputTokens !== null && cached <= inputTokens ? inputTokens - cached : null,
151
+ cacheWriteInputTokens: null,
152
+ };
153
+ const current = { inputTokens, outputTokens: number(reported?.completion_tokens), costUsd: number(reported?.cost_usd ?? data?.cost_usd), ...cache };
154
+ this.usage = { inputTokens: add(this.usage.inputTokens, current.inputTokens), outputTokens: add(this.usage.outputTokens, current.outputTokens), costUsd: add(this.usage.costUsd, current.costUsd), ...(this.responses === 0 ? cache : sumCacheUsage([this.usage, current])) };
155
+ this.responses++;
156
+ options.onEvent?.({ kind: 'usage', usage: { ...this.usage } });
157
+ if (options.maxTokens !== undefined && (this.usage.inputTokens === null || this.usage.outputTokens === null))
158
+ throw new AgentExecutionError('Provider omitted usage required by the token budget', 'usage_unavailable', this.usage);
159
+ if (options.maxTokens !== undefined && (this.usage.inputTokens ?? 0) + (this.usage.outputTokens ?? 0) > options.maxTokens)
160
+ throw new AgentExecutionError('Agent token budget exceeded', 'token_budget', this.usage);
161
+ if (options.maxCostUsd !== undefined && this.usage.costUsd !== null && this.usage.costUsd > options.maxCostUsd)
162
+ throw new AgentExecutionError('Agent cost budget exceeded', 'cost_budget', this.usage);
163
+ if (!data || data.error)
164
+ throw new AgentExecutionError('Provider returned an error or invalid response', 'provider_response_error', this.usage);
165
+ const choice = Array.isArray(data.choices) ? record(data.choices[0]) : undefined;
166
+ const message = record(choice?.message);
167
+ if (!message || message.role !== 'assistant')
168
+ throw new AgentExecutionError('Provider response has no assistant message', 'invalid_response', this.usage);
169
+ if (choice?.finish_reason === 'length' || choice?.finish_reason === 'content_filter')
170
+ throw new AgentExecutionError('Provider did not complete the requested result', 'incomplete_response', this.usage);
171
+ return { message, finishReason: choice?.finish_reason };
172
+ }
173
+ /**
174
+ * A tool-less call whose reply must be one JSON object. Uses `response_format`
175
+ * json_schema when the endpoint accepts it; an endpoint that rejects the field
176
+ * (HTTP 4xx on the first structured call) falls back to instructions only.
177
+ */
178
+ async completeStructured(messages, name, schema, controls = {}) {
179
+ if (this.structuredOutput !== 'unsupported') {
180
+ try {
181
+ const result = await this.complete({ messages, response_format: { type: 'json_schema', json_schema: { name, schema, strict: false } } }, controls);
182
+ this.structuredOutput = 'supported';
183
+ return result;
184
+ }
185
+ catch (error) {
186
+ if (this.structuredOutput === 'supported' || !(error instanceof AgentExecutionError) || error.code !== 'provider_http_error')
187
+ throw error;
188
+ this.structuredOutput = 'unsupported';
189
+ }
190
+ }
191
+ return this.complete({ messages: [...messages, { role: 'user', content: 'Reply with exactly one JSON object matching this JSON Schema and nothing else:\n' + JSON.stringify(schema) }] }, controls);
192
+ }
193
+ }
194
+ /**
195
+ * Reads a chat completion whether the server streamed it (SSE — the request
196
+ * asks for it, so a model that reasons for minutes before its first token
197
+ * never trips the client's headers timeout) or answered with one JSON body
198
+ * (servers and fixtures that ignore `stream`). The result has the classic
199
+ * non-streaming shape: `{ choices: [{ message, finish_reason }], usage }`.
200
+ */
201
+ export async function readCompletionResponse(response) {
202
+ const type = response.headers.get('content-type') ?? '';
203
+ if (!/text\/event-stream/i.test(type))
204
+ return readBoundedResponse(response);
205
+ if (!response.body)
206
+ throw new Error('Missing response body');
207
+ const reader = response.body.getReader(), decoder = new TextDecoder();
208
+ let buffer = '', length = 0, content = '', finishReason = null, usage, error;
209
+ const calls = new Map();
210
+ const consume = (line) => {
211
+ if (!line.startsWith('data:'))
212
+ return;
213
+ const payload = line.slice(5).trim();
214
+ if (!payload || payload === '[DONE]')
215
+ return;
216
+ let chunk;
217
+ try {
218
+ chunk = record(JSON.parse(payload));
219
+ }
220
+ catch {
221
+ return;
222
+ }
223
+ if (!chunk)
224
+ return;
225
+ if (chunk.error)
226
+ error = chunk.error;
227
+ if (chunk.usage)
228
+ usage = chunk.usage;
229
+ const choice = Array.isArray(chunk.choices) ? record(chunk.choices[0]) : undefined;
230
+ if (!choice)
231
+ return;
232
+ if (choice.finish_reason)
233
+ finishReason = choice.finish_reason;
234
+ const delta = record(choice.delta);
235
+ if (typeof delta?.content === 'string')
236
+ content += delta.content;
237
+ for (const raw of Array.isArray(delta?.tool_calls) ? delta.tool_calls : []) {
238
+ const item = record(raw);
239
+ if (!item)
240
+ continue;
241
+ const index = typeof item.index === 'number' ? item.index : calls.size;
242
+ const fn = record(item.function);
243
+ const current = calls.get(index) ?? { id: '', type: 'function', function: { name: '', arguments: '' } };
244
+ if (typeof item.id === 'string' && item.id)
245
+ current.id = item.id;
246
+ if (typeof fn?.name === 'string' && fn.name)
247
+ current.function.name += fn.name;
248
+ if (typeof fn?.arguments === 'string')
249
+ current.function.arguments += fn.arguments;
250
+ calls.set(index, current);
251
+ }
252
+ };
253
+ try {
254
+ for (;;) {
255
+ const part = await reader.read();
256
+ if (part.done)
257
+ break;
258
+ length += part.value.byteLength;
259
+ if (length > 8 * 1024 * 1024) {
260
+ await reader.cancel();
261
+ throw new Error('Provider response exceeds 8 MiB');
262
+ }
263
+ buffer += decoder.decode(part.value, { stream: true });
264
+ let index;
265
+ while ((index = buffer.indexOf('\n')) >= 0) {
266
+ consume(buffer.slice(0, index).replace(/\r$/, ''));
267
+ buffer = buffer.slice(index + 1);
268
+ }
269
+ }
270
+ if (buffer.trim())
271
+ consume(buffer.trim());
272
+ }
273
+ finally {
274
+ reader.releaseLock();
275
+ }
276
+ if (error)
277
+ return { error };
278
+ const toolCalls = [...calls.entries()].sort((a, b) => a[0] - b[0]).map(([, call], n) => ({ ...call, id: call.id || `call_${n}` }));
279
+ const message = { role: 'assistant', content: content || (toolCalls.length ? null : '') };
280
+ if (toolCalls.length)
281
+ message.tool_calls = toolCalls;
282
+ return { choices: [{ message, finish_reason: finishReason ?? (toolCalls.length ? 'tool_calls' : 'stop') }], ...(usage ? { usage } : {}) };
283
+ }
284
+ export async function readBoundedResponse(response) {
285
+ if (!response.body)
286
+ throw new Error('Missing response body');
287
+ const reader = response.body.getReader(), chunks = [];
288
+ let length = 0;
289
+ try {
290
+ for (;;) {
291
+ const part = await reader.read();
292
+ if (part.done)
293
+ break;
294
+ length += part.value.byteLength;
295
+ if (length > 2 * 1024 * 1024) {
296
+ await reader.cancel();
297
+ throw new Error('Provider response exceeds 2 MiB');
298
+ }
299
+ chunks.push(part.value);
300
+ }
301
+ }
302
+ finally {
303
+ reader.releaseLock();
304
+ }
305
+ return JSON.parse(Buffer.concat(chunks).toString('utf8'));
306
+ }
307
+ //# sourceMappingURL=chat-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-client.js","sourceRoot":"","sources":["../../../src/agent-runtime/compact/chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAoC,MAAM,sBAAsB,CAAA;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAGtD;;;;;;;GAOG;AACH,IAAI,iBAA0B,CAAA;AAC9B,SAAS,wBAAwB;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAA;QACtH,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAE,UAAsC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACpF,MAAM,KAAK,GAAG,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAE,OAA8E,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;QAC9J,IAAI,KAAK;YAAE,iBAAiB,GAAG,IAAI,KAAK,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CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;AAC3I,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAkB;IAC1D,IAAI,CAAC,QAAQ,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,MAAM,GAAiB,EAAE,CAAA;IACnE,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;YAChC,IAAI,IAAI,CAAC,IAAI;gBAAE,MAAK;YACpB,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAA;YAC/B,IAAI,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;gBAAC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;gBAAC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;YAAC,CAAC;YAC3G,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;YAAS,CAAC;QAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IAAC,CAAC;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AAC3D,CAAC"}
@@ -0,0 +1,160 @@
1
+ import type { ChatMessage } from './chat-client.js';
2
+ import { type AgentResult } from '../executor-types.js';
3
+ import { type CompactEnv } from './step.js';
4
+ /** Tool calls one task group may spend before it must report. */
5
+ export declare const DEFAULT_TASK_TOOL_BUDGET = 25;
6
+ export declare const TASK_RESULT_SCHEMA: {
7
+ type: string;
8
+ additionalProperties: boolean;
9
+ required: string[];
10
+ properties: {
11
+ summary: {
12
+ type: string;
13
+ };
14
+ files: {
15
+ type: string;
16
+ items: {
17
+ type: string;
18
+ };
19
+ };
20
+ tests: {
21
+ type: string;
22
+ items: {
23
+ type: string;
24
+ };
25
+ };
26
+ verification: {
27
+ type: string;
28
+ };
29
+ incomplete: {
30
+ type: string;
31
+ items: {
32
+ type: string;
33
+ additionalProperties: boolean;
34
+ required: string[];
35
+ properties: {
36
+ task: {
37
+ type: string;
38
+ };
39
+ reason: {
40
+ type: string;
41
+ };
42
+ };
43
+ };
44
+ };
45
+ };
46
+ };
47
+ export interface TaskGroup {
48
+ index: number;
49
+ title: string;
50
+ tasks: {
51
+ id: string;
52
+ text: string;
53
+ done: boolean;
54
+ }[];
55
+ }
56
+ /** Parses the `## N. Title` / `- [ ] N.M text` layout the OpenSpec tasks template prescribes. */
57
+ export declare function parseTaskGroups(markdown: string): TaskGroup[];
58
+ /** Paths written or patched by successful tool calls in a loop transcript. */
59
+ export declare function writtenFiles(messages: readonly ChatMessage[]): string[];
60
+ /** Relative source/test paths a task sentence names (`src/game.js`, `tests/smoke.test.js`). */
61
+ export declare function namedFiles(task: string): string[];
62
+ /**
63
+ * Turns the two failure shapes small models never fix on their own into
64
+ * concrete, file-precise correction items: an import that resolves to a file
65
+ * that does not exist (the host locates the real one), and a missing module.
66
+ * Generic Node/Jest/TS and Python signatures; anything else passes through.
67
+ */
68
+ export declare function diagnoseVerificationFailure(feedback: string, roots: readonly string[]): string[];
69
+ /** Application source/test files under the roots (bounded), excluding plans, deps and dot dirs. */
70
+ export declare function repositoryInventory(roots: readonly string[], limit?: number): string[];
71
+ export interface LanguageProfile {
72
+ primary: string;
73
+ others: string[];
74
+ }
75
+ /**
76
+ * The repository's primary language (most source files; a tsconfig.json or a
77
+ * TypeScript `main` breaks a JS/TS tie towards TypeScript) plus every other
78
+ * language present. Advisory: a mixed repository keeps every language, the
79
+ * profile only tells the model which one NEW files default to.
80
+ */
81
+ export declare function languageProfile(roots: readonly string[]): LanguageProfile | undefined;
82
+ /**
83
+ * A new file that would duplicate an existing sibling in the primary language
84
+ * (`src/board.js` next to `src/board.ts`): the sibling to extend, else undefined.
85
+ * Rewriting an existing file or adding a file in a secondary language with no
86
+ * primary-language twin is never flagged, so mixed repositories keep working.
87
+ */
88
+ export declare function duplicateSibling(roots: readonly string[], file: string, primary: string): string | undefined;
89
+ /**
90
+ * A NEW source file in a language the repository does not use at all
91
+ * (`src/feature.ts` in a JavaScript-only game): the reason to refuse, else
92
+ * undefined. Only fires when the repository is monolingual — a mixed
93
+ * repository may legitimately grow a second language — and never for
94
+ * rewrites, config/data files or a language family sibling (a .ts repo
95
+ * adding .tsx is fine).
96
+ */
97
+ export declare function foreignLanguageFile(roots: readonly string[], file: string, languages: LanguageProfile): string | undefined;
98
+ /** Existing test directories (relative, POSIX) among the conventional names, e.g. `tests`, `test`, `__tests__`, `spec`. */
99
+ export declare function existingTestDirs(roots: readonly string[]): string[];
100
+ /**
101
+ * A NEW test file outside the directory the repository already keeps its
102
+ * tests in (`src/hold.test.js` next to an existing `tests/`): the reason to
103
+ * refuse, else undefined. Co-located tests (`foo.test.js` beside `foo.js`)
104
+ * are accepted when the repository has no test directory at all.
105
+ */
106
+ export declare function misplacedTestFile(roots: readonly string[], file: string): string | undefined;
107
+ /**
108
+ * For a NEW test file whose name extends a module's canonical test file
109
+ * (`tests/board.tick.test.ts` next to `tests/board.test.ts`), that canonical
110
+ * file; else undefined. The canonical file itself and rewrites never flag.
111
+ */
112
+ export declare function siblingTestFile(roots: readonly string[], file: string): string | undefined;
113
+ /** The absolute path a task-named file resolves to: the exact path, else the same stem in a sibling extension of the same language family. */
114
+ export declare function locateNamedFile(roots: readonly string[], file: string): string | undefined;
115
+ /** Extra tool calls a correction group gets on top of the task budget: it must read AND patch, and the feedback is long. */
116
+ export declare const CORRECTION_BUDGET_BONUS = 10;
117
+ /**
118
+ * Source excerpts around every `file:line` the feedback names (Jest/Babel
119
+ * `path/file.js: … (30:56)`, TS `file.ts(12,3)` / `file.ts:12:3`, mocha
120
+ * `at … (file.js:44:9)`), read by the HOST so a correction round starts with
121
+ * the offending lines in front of the model instead of spending its tool
122
+ * budget re-reading the whole repository (observed: 19 reads, 2 patches).
123
+ */
124
+ export declare function feedbackExcerpts(feedback: string, roots: readonly string[], options?: {
125
+ context?: number;
126
+ maxBytes?: number;
127
+ }): string;
128
+ /** An existing file this long is edited with apply_patch, never regenerated whole (observed: a 1.4k-line test rewritten twice in one group, ~25 minutes of generation). */
129
+ export declare const REWRITE_MAX_LINES = 150;
130
+ /** Above this many lines, `read_file` answers with an outline (head + index of definitions) instead of the whole file. */
131
+ export declare const OUTLINE_MIN_LINES = 400;
132
+ /**
133
+ * A large file as an outline: the first lines (imports, top-level state) and
134
+ * an index of definitions with their line numbers, so the model asks for the
135
+ * range it needs with read_lines instead of putting 15k tokens of test file
136
+ * into the transcript on every read (observed: 4-minute prefills).
137
+ */
138
+ export declare function outlineLargeFile(file: string, content: string): string | undefined;
139
+ /** Files a model writes to narrate its own work; never part of a task, always noise for the reviewer (observed: fix_summary.json, task-summary.json in the repository root). */
140
+ export declare const NARRATION_FILE: RegExp;
141
+ /** Media/binary extensions a text-only tool can never produce correctly. */
142
+ export declare const BINARY_ASSET: RegExp;
143
+ /** Extra write-only calls a task group gets when it spent its whole budget reading. */
144
+ export declare const WRITE_EXTENSION_CALLS = 6;
145
+ /** Tool calls the in-place fix round after a failed group check may spend. */
146
+ export declare const GROUP_FIX_BUDGET = 20;
147
+ /** Test files among `reported` that the repository's own test command (per root) does not execute; empty when no command is detected. */
148
+ export declare function unreachedGroupTests(roots: readonly string[], reported: readonly string[]): string[];
149
+ /** A source file that exists but carries no implementation: a handful of lines, a placeholder import, or only TODOs. */
150
+ export declare function isStubFile(file: string, minLines?: number): boolean;
151
+ /** Ticks the given task ids; every other byte of tasks.md is preserved, as the developer write rule requires. */
152
+ export declare function tickTasks(markdown: string, ids: Set<string>): string;
153
+ /**
154
+ * The compact developer: one bounded mini-loop per task group with the full
155
+ * developer tool set, the host ticking tasks.md and saving progress after each
156
+ * group, and the DEVELOPER_OUTPUT_SCHEMA object assembled from the group results.
157
+ */
158
+ export declare function runCompactDeveloper(env: CompactEnv, options?: {
159
+ taskToolBudget?: number;
160
+ }): Promise<AgentResult>;