@mikode13/harness 0.1.0 → 1.0.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.
- package/README.md +41 -25
- package/dist/agent/domain/agent.d.ts +5 -1
- package/dist/agent/domain/agent.js.map +1 -1
- package/dist/agent/domain/errors.d.ts +6 -1
- package/dist/agent/domain/errors.js +6 -0
- package/dist/agent/domain/errors.js.map +1 -1
- package/dist/agent/domain/providerFailure.d.ts +6 -1
- package/dist/agent/domain/providerFailure.js +13 -0
- package/dist/agent/domain/providerFailure.js.map +1 -1
- package/dist/engines/claude/infrastructure/model/claudeAgent.d.ts +14 -5
- package/dist/engines/claude/infrastructure/model/claudeAgent.js +142 -29
- package/dist/engines/claude/infrastructure/model/claudeAgent.js.map +1 -1
- package/dist/engines/codex/infrastructure/model/codexAgent.d.ts +8 -9
- package/dist/engines/codex/infrastructure/model/codexAgent.js +35 -8
- package/dist/engines/codex/infrastructure/model/codexAgent.js.map +1 -1
- package/dist/factory/infrastructure/agentFactory.d.ts +49 -0
- package/dist/factory/infrastructure/agentFactory.js +91 -0
- package/dist/factory/infrastructure/agentFactory.js.map +1 -0
- package/dist/index.d.ts +2 -9
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/orchestration/domain/interface/validator.d.ts +0 -1
- package/dist/orchestration/domain/interface/validator.js.map +1 -1
- package/dist/orchestration/domain/model/orchestratorAgent.d.ts +11 -2
- package/dist/orchestration/domain/model/orchestratorAgent.js +13 -1
- package/dist/orchestration/domain/model/orchestratorAgent.js.map +1 -1
- package/dist/orchestration/domain/model/reviewerDecision.d.ts +0 -1
- package/dist/orchestration/domain/model/reviewerDecision.js.map +1 -1
- package/dist/orchestration/infrastructure/model/reviewerDecisionValidator.d.ts +0 -1
- package/dist/orchestration/infrastructure/model/reviewerDecisionValidator.js.map +1 -1
- package/dist/retry/domain/model/retryingAgent.d.ts +7 -2
- package/dist/retry/domain/model/retryingAgent.js +13 -3
- package/dist/retry/domain/model/retryingAgent.js.map +1 -1
- package/dist/shared/domain/isAbortError.d.ts +0 -1
- package/dist/shared/domain/isAbortError.js.map +1 -1
- package/dist/shared/domain/isOneOf.d.ts +2 -0
- package/dist/shared/domain/isOneOf.js +5 -0
- package/dist/shared/domain/isOneOf.js.map +1 -0
- package/dist/shared/domain/logger.d.ts +0 -3
- package/dist/shared/domain/logger.js.map +1 -1
- package/dist/shared/infrastructure/logger.d.ts +4 -0
- package/dist/shared/infrastructure/logger.js +6 -0
- package/dist/shared/infrastructure/logger.js.map +1 -0
- package/package.json +60 -57
- package/dist/agent/domain/agent.d.ts.map +0 -1
- package/dist/agent/domain/errors.d.ts.map +0 -1
- package/dist/agent/domain/providerFailure.d.ts.map +0 -1
- package/dist/engines/claude/infrastructure/model/claudeAgent.d.ts.map +0 -1
- package/dist/engines/codex/infrastructure/model/codexAgent.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/orchestration/domain/interface/validator.d.ts.map +0 -1
- package/dist/orchestration/domain/model/orchestratorAgent.d.ts.map +0 -1
- package/dist/orchestration/domain/model/reviewerDecision.d.ts.map +0 -1
- package/dist/orchestration/infrastructure/model/reviewerDecisionValidator.d.ts.map +0 -1
- package/dist/retry/domain/model/retryingAgent.d.ts.map +0 -1
- package/dist/shared/domain/isAbortError.d.ts.map +0 -1
- package/dist/shared/domain/logger.d.ts.map +0 -1
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import { Codex, } from '@openai/codex-sdk';
|
|
1
2
|
import {} from "../../../../agent/domain/agent.js";
|
|
2
|
-
import { RecoverableError, UnrecoverableError } from "../../../../agent/domain/errors.js";
|
|
3
|
-
import { classifiedProviderStream, classifyHostFailure, classifyLocalFailure, classifyProviderFailure, describeFailure, } from "../../../../agent/domain/providerFailure.js";
|
|
3
|
+
import { InvalidAgentConfigError, RecoverableError, UnrecoverableError, } from "../../../../agent/domain/errors.js";
|
|
4
|
+
import { classifiedProviderStream, classifyHostFailure, classifyLocalFailure, classifyProviderFailure, describeFailure, treatErrors, } from "../../../../agent/domain/providerFailure.js";
|
|
5
|
+
import { isOneOf } from "../../../../shared/domain/isOneOf.js";
|
|
6
|
+
// The SDK types `model` as a plain string, so this list is maintained by hand.
|
|
7
|
+
export const codexModels = ['gpt-6-astra', 'gpt-5.6-sol', 'gpt-5.6-luna', 'gpt-5.6-terra'];
|
|
8
|
+
// The efforts Codex's model catalog lists; the SDK also types 'minimal' and 'persistent', which
|
|
9
|
+
// none of the models above supports. `satisfies` only proves this is a subset of the SDK's type,
|
|
10
|
+
// so an SDK upgrade that adds an effort has to be reconciled here by hand.
|
|
11
|
+
export const codexReasoningEfforts = [
|
|
12
|
+
'low',
|
|
13
|
+
'medium',
|
|
14
|
+
'high',
|
|
15
|
+
'xhigh',
|
|
16
|
+
'max',
|
|
17
|
+
'ultra',
|
|
18
|
+
];
|
|
4
19
|
function convertEventToItem(event) {
|
|
5
20
|
if (event.type === 'error')
|
|
6
21
|
throw new UnrecoverableError('Codex stream error', { cause: event.message });
|
|
@@ -33,20 +48,32 @@ function describeItem(item, logger) {
|
|
|
33
48
|
case 'error':
|
|
34
49
|
throw new RecoverableError('error while using the codex tools', { cause: item.message });
|
|
35
50
|
default:
|
|
36
|
-
|
|
51
|
+
treatErrors(() => {
|
|
37
52
|
logger.warn(item, 'new type');
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
throw classifyHostFailure(error, 'Codex logger failed while reporting progress');
|
|
41
|
-
}
|
|
53
|
+
}, classifyHostFailure, 'Codex logger failed while reporting progress');
|
|
42
54
|
return undefined;
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
export class CodexAgent {
|
|
46
58
|
thread;
|
|
47
59
|
logger;
|
|
48
|
-
|
|
60
|
+
// `model` and `reasoningEffort` are untyped on purpose: this adapter is the one that knows
|
|
61
|
+
// what Codex supports, so it validates them instead of trusting the caller.
|
|
62
|
+
constructor({ model, autoApprove = false, reasoningEffort = 'high', logger, }) {
|
|
63
|
+
// Checked before the SDK is involved: an unsupported value is the caller's mistake, not
|
|
64
|
+
// a configuration Codex rejected.
|
|
65
|
+
if (!isOneOf(codexModels, model)) {
|
|
66
|
+
throw new InvalidAgentConfigError(`"${model}" is not a Codex model; expected one of: ${codexModels.join(', ')}`);
|
|
67
|
+
}
|
|
68
|
+
if (!isOneOf(codexReasoningEfforts, reasoningEffort)) {
|
|
69
|
+
throw new InvalidAgentConfigError(`"${reasoningEffort}" is not a Codex reasoning effort; expected one of: ${codexReasoningEfforts.join(', ')}`);
|
|
70
|
+
}
|
|
71
|
+
// The one per-model gap in Codex's catalog.
|
|
72
|
+
if (model === 'gpt-5.6-luna' && reasoningEffort === 'ultra') {
|
|
73
|
+
throw new InvalidAgentConfigError('"gpt-5.6-luna" does not support the "ultra" reasoning effort');
|
|
74
|
+
}
|
|
49
75
|
try {
|
|
76
|
+
const sdk = new Codex();
|
|
50
77
|
this.thread = sdk.startThread({
|
|
51
78
|
model,
|
|
52
79
|
modelReasoningEffort: reasoningEffort,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codexAgent.js","sourceRoot":"","sources":["../../../../../src/engines/codex/infrastructure/model/codexAgent.ts"],"names":[],"mappings":"AAQA,OAAO,EAKN,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EACN,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,GACf,MAAM,6CAA6C,CAAC;AASrD,SAAS,kBAAkB,CAAC,KAAkB;IAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QACzB,MAAM,IAAI,kBAAkB,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9E,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa;QAC/B,MAAM,IAAI,kBAAkB,CAAC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C,CAAC,CAAC;gBACpE,CAAC;YACF,CAAC;YACD,IAAI,WAAW,EAAE,IAAI,KAAK,cAAc;gBAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,OAAO;YACN,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1B,WAAW,EAAE,KAAK,CAAC,YAAY;YAC/B,YAAY,EAAE,KAAK,CAAC,aAAa;YACjC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI;SACrC,CAAC;IACH,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"codexAgent.js","sourceRoot":"","sources":["../../../../../src/engines/codex/infrastructure/model/codexAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAML,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAKN,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,WAAW,GACX,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAE/D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,CAAU,CAAC;AAGpG,gGAAgG;AAChG,iGAAiG;AACjG,2EAA2E;AAC3E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;CAC4C,CAAC;AAOrD,SAA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IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI;SACrC,CAAC;IACH,CAAC;CACD","sourcesContent":["import {\n\tCodex,\n\ttype ModelReasoningEffort,\n\ttype Thread,\n\ttype ThreadEvent,\n\ttype ThreadItem,\n\ttype Usage,\n} from '@openai/codex-sdk';\nimport {\n\ttype Agent,\n\ttype AgentResponse,\n\ttype Callback,\n\ttype ProgressEvent,\n} from '../../../../agent/domain/agent.ts';\nimport {\n\tInvalidAgentConfigError,\n\tRecoverableError,\n\tUnrecoverableError,\n} from '../../../../agent/domain/errors.ts';\nimport {\n\tclassifiedProviderStream,\n\tclassifyHostFailure,\n\tclassifyLocalFailure,\n\tclassifyProviderFailure,\n\tdescribeFailure,\n\ttreatErrors,\n} from '../../../../agent/domain/providerFailure.ts';\nimport type { ILogger } from '../../../../shared/domain/logger.ts';\nimport { isOneOf } from '../../../../shared/domain/isOneOf.ts';\n\n// The SDK types `model` as a plain string, so this list is maintained by hand.\nexport const codexModels = ['gpt-6-astra', 'gpt-5.6-sol', 'gpt-5.6-luna', 'gpt-5.6-terra'] as const;\nexport type CodexModel = (typeof codexModels)[number];\n\n// The efforts Codex's model catalog lists; the SDK also types 'minimal' and 'persistent', which\n// none of the models above supports. `satisfies` only proves this is a subset of the SDK's type,\n// so an SDK upgrade that adds an effort has to be reconciled here by hand.\nexport const codexReasoningEfforts = [\n\t'low',\n\t'medium',\n\t'high',\n\t'xhigh',\n\t'max',\n\t'ultra',\n] as const satisfies readonly ModelReasoningEffort[];\nexport type CodexReasoningEffort = (typeof codexReasoningEfforts)[number];\n\ninterface StreamedTurn {\n\tevents: AsyncGenerator<ThreadEvent>;\n}\n\nfunction convertEventToItem(event: ThreadEvent): ThreadItem | undefined {\n\tif (event.type === 'error')\n\t\tthrow new UnrecoverableError('Codex stream error', { cause: event.message });\n\n\tif (event.type === 'turn.failed')\n\t\tthrow new UnrecoverableError('Turn failed from codex sdk', { cause: event.error.message });\n\n\tif (event.type === 'item.completed') return event.item;\n\n\treturn undefined;\n}\n\nfunction describeItem(item: ThreadItem, logger: ILogger): ProgressEvent | undefined {\n\tswitch (item.type) {\n\t\tcase 'agent_message':\n\t\t\treturn { type: 'agentMessage', message: item.text };\n\t\tcase 'reasoning':\n\t\t\treturn { type: 'reasoning', message: item.text };\n\t\tcase 'command_execution':\n\t\t\treturn { type: 'command', command: item.command, exitCode: item.exit_code };\n\t\tcase 'web_search':\n\t\t\treturn { type: 'search', query: item.query };\n\t\tcase 'file_change':\n\t\t\treturn { type: 'fileChange', changes: item.changes };\n\t\tcase 'mcp_tool_call': {\n\t\t\tif (item.error) {\n\t\t\t\tthrow new RecoverableError('skill failed', { cause: item.error.message });\n\t\t\t}\n\t\t\treturn { type: 'mcpTool', server: item.server, tool: item.tool, status: item.status };\n\t\t}\n\t\tcase 'todo_list':\n\t\t\treturn { type: 'todoList', items: item.items };\n\t\tcase 'error':\n\t\t\tthrow new RecoverableError('error while using the codex tools', { cause: item.message });\n\t\tdefault:\n\t\t\ttreatErrors(\n\t\t\t\t() => {\n\t\t\t\t\tlogger.warn(item, 'new type');\n\t\t\t\t},\n\t\t\t\tclassifyHostFailure,\n\t\t\t\t'Codex logger failed while reporting progress',\n\t\t\t);\n\t\t\treturn undefined;\n\t}\n}\n\nexport class CodexAgent implements Agent {\n\tprivate thread: Thread;\n\tprivate logger: ILogger;\n\n\t// `model` and `reasoningEffort` are untyped on purpose: this adapter is the one that knows\n\t// what Codex supports, so it validates them instead of trusting the caller.\n\tconstructor({\n\t\tmodel,\n\t\tautoApprove = false,\n\t\treasoningEffort = 'high',\n\t\tlogger,\n\t}: {\n\t\tmodel: string;\n\t\tautoApprove?: boolean;\n\t\treasoningEffort?: string;\n\t\tlogger: ILogger;\n\t}) {\n\t\t// Checked before the SDK is involved: an unsupported value is the caller's mistake, not\n\t\t// a configuration Codex rejected.\n\t\tif (!isOneOf(codexModels, model)) {\n\t\t\tthrow new InvalidAgentConfigError(\n\t\t\t\t`\"${model}\" is not a Codex model; expected one of: ${codexModels.join(', ')}`,\n\t\t\t);\n\t\t}\n\t\tif (!isOneOf(codexReasoningEfforts, reasoningEffort)) {\n\t\t\tthrow new InvalidAgentConfigError(\n\t\t\t\t`\"${reasoningEffort}\" is not a Codex reasoning effort; expected one of: ${codexReasoningEfforts.join(', ')}`,\n\t\t\t);\n\t\t}\n\t\t// The one per-model gap in Codex's catalog.\n\t\tif (model === 'gpt-5.6-luna' && reasoningEffort === 'ultra') {\n\t\t\tthrow new InvalidAgentConfigError(\n\t\t\t\t'\"gpt-5.6-luna\" does not support the \"ultra\" reasoning effort',\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst sdk = new Codex();\n\t\t\tthis.thread = sdk.startThread({\n\t\t\t\tmodel,\n\t\t\t\tmodelReasoningEffort: reasoningEffort,\n\t\t\t\t...(autoApprove\n\t\t\t\t\t? { approvalPolicy: 'never' as const, sandboxMode: 'danger-full-access' as const }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// Not recoverable, unlike a request: a thread the SDK refused to open at all is\n\t\t\t// rejected configuration, and running the same constructor again cannot fix it.\n\t\t\tthrow new UnrecoverableError('Codex rejected the thread configuration', {\n\t\t\t\tcause: describeFailure(error),\n\t\t\t});\n\t\t}\n\n\t\tthis.logger = logger;\n\t}\n\n\tasync run(\n\t\tprompt: string,\n\t\tsignal: AbortSignal,\n\t\tcallback: Callback,\n\t): Promise<AgentResponse | undefined> {\n\t\tlet turn: StreamedTurn;\n\n\t\ttry {\n\t\t\tturn = await this.thread.runStreamed(prompt, { signal });\n\t\t} catch (error) {\n\t\t\tthrow classifyProviderFailure(error, 'Codex refused the request');\n\t\t}\n\n\t\treturn await this.parseResponse(turn, callback);\n\t}\n\n\tprivate async parseResponse(\n\t\tturn: StreamedTurn,\n\t\tcallback: Callback,\n\t): Promise<AgentResponse | undefined> {\n\t\tconst lines: string[] = [];\n\t\tconst start = Date.now();\n\t\tlet usage: Usage | undefined = undefined;\n\n\t\tconst events = classifiedProviderStream(turn.events, 'Codex stream ended unexpectedly');\n\n\t\tfor await (const event of events) {\n\t\t\tif (event.type === 'turn.completed') {\n\t\t\t\tusage = event.usage;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst item = convertEventToItem(event);\n\n\t\t\tif (!item) continue;\n\n\t\t\tlet description: ProgressEvent | undefined;\n\t\t\ttry {\n\t\t\t\tdescription = describeItem(item, this.logger);\n\t\t\t} catch (error) {\n\t\t\t\tthrow classifyLocalFailure(error, 'Codex failed while mapping progress');\n\t\t\t}\n\n\t\t\tif (description) {\n\t\t\t\ttry {\n\t\t\t\t\tcallback(description);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow classifyHostFailure(error, 'Codex progress callback failed');\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (description?.type === 'agentMessage') lines.push(description.message);\n\t\t}\n\n\t\tif (!lines.length || !usage) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: lines.join('\\n'),\n\t\t\tinputTokens: usage.input_tokens,\n\t\t\toutputTokens: usage.output_tokens,\n\t\t\tduration: (Date.now() - start) / 1000,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Agent } from '../../agent/domain/agent.ts';
|
|
2
|
+
import { type ClaudeModel, type ClaudeReasoningEffort } from '../../engines/claude/infrastructure/model/claudeAgent.ts';
|
|
3
|
+
import { type CodexModel, type CodexReasoningEffort } from '../../engines/codex/infrastructure/model/codexAgent.ts';
|
|
4
|
+
import type { ILogger } from '../../shared/domain/logger.ts';
|
|
5
|
+
export declare const agentProviders: readonly ["claude", "codex"];
|
|
6
|
+
export type AgentProvider = (typeof agentProviders)[number];
|
|
7
|
+
/** Any provider's model. The engine the provider selects rejects one it does not support. */
|
|
8
|
+
export type AgentModel = ClaudeModel | CodexModel;
|
|
9
|
+
/** Any provider's reasoning effort. The engine the provider selects rejects one it does not support. */
|
|
10
|
+
export type ReasoningEffort = ClaudeReasoningEffort | CodexReasoningEffort;
|
|
11
|
+
export declare function isAgentProvider(value: string): value is AgentProvider;
|
|
12
|
+
export interface CreateAgentOptions {
|
|
13
|
+
/** Defaults to `'opus'` on Claude and `'gpt-5.6-sol'` on Codex. */
|
|
14
|
+
model?: AgentModel;
|
|
15
|
+
/** Defaults to `'high'`. */
|
|
16
|
+
reasoningEffort?: ReasoningEffort;
|
|
17
|
+
/** Maps to the provider's permission-bypass mode. Defaults to `false`. */
|
|
18
|
+
autoApprove?: boolean;
|
|
19
|
+
/** Defaults to warnings on stderr. */
|
|
20
|
+
logger?: ILogger;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds the agent for a provider, already wrapped in the harness's retry policy.
|
|
24
|
+
*
|
|
25
|
+
* @throws {InvalidAgentConfigError} for an unknown provider, or a model or reasoning effort
|
|
26
|
+
* the provider does not support.
|
|
27
|
+
* @throws {UnrecoverableError} when Codex cannot be set up, for example because its CLI binary
|
|
28
|
+
* is missing.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createAgent(provider: AgentProvider, { model, reasoningEffort, autoApprove, logger }?: CreateAgentOptions): Agent;
|
|
31
|
+
export interface CreateOrchestratorOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Runs every role on one provider, for example when the other one is out of quota. By
|
|
34
|
+
* default Codex plans and executes, and Claude reviews.
|
|
35
|
+
*/
|
|
36
|
+
provider?: AgentProvider;
|
|
37
|
+
/** Maps to each provider's permission-bypass mode. Defaults to `false`. */
|
|
38
|
+
autoApprove?: boolean;
|
|
39
|
+
/** Defaults to warnings on stderr. */
|
|
40
|
+
logger?: ILogger;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Builds the planner → executor → reviewer workflow, each role an agent from `createAgent`.
|
|
44
|
+
*
|
|
45
|
+
* @throws {InvalidAgentConfigError} for an unknown provider.
|
|
46
|
+
* @throws {UnrecoverableError} when a Codex role cannot be set up, for example because its CLI
|
|
47
|
+
* binary is missing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createOrchestrator({ provider, autoApprove, logger, }?: CreateOrchestratorOptions): Agent;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { InvalidAgentConfigError } from "../../agent/domain/errors.js";
|
|
2
|
+
import { ClaudeAgent, } from "../../engines/claude/infrastructure/model/claudeAgent.js";
|
|
3
|
+
import { CodexAgent, } from "../../engines/codex/infrastructure/model/codexAgent.js";
|
|
4
|
+
import { OrchestratorAgent } from "../../orchestration/domain/model/orchestratorAgent.js";
|
|
5
|
+
import { ReviewerDecisionValidator } from "../../orchestration/infrastructure/model/reviewerDecisionValidator.js";
|
|
6
|
+
import { RetryingAgent } from "../../retry/domain/model/retryingAgent.js";
|
|
7
|
+
import { isOneOf } from "../../shared/domain/isOneOf.js";
|
|
8
|
+
import { Logger } from "../../shared/infrastructure/logger.js";
|
|
9
|
+
export const agentProviders = ['claude', 'codex'];
|
|
10
|
+
export function isAgentProvider(value) {
|
|
11
|
+
return isOneOf(agentProviders, value);
|
|
12
|
+
}
|
|
13
|
+
const defaultModels = {
|
|
14
|
+
claude: 'opus',
|
|
15
|
+
codex: 'gpt-5.6-sol',
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Builds the agent for a provider, already wrapped in the harness's retry policy.
|
|
19
|
+
*
|
|
20
|
+
* @throws {InvalidAgentConfigError} for an unknown provider, or a model or reasoning effort
|
|
21
|
+
* the provider does not support.
|
|
22
|
+
* @throws {UnrecoverableError} when Codex cannot be set up, for example because its CLI binary
|
|
23
|
+
* is missing.
|
|
24
|
+
*/
|
|
25
|
+
export function createAgent(provider, { model, reasoningEffort, autoApprove, logger = new Logger() } = {}) {
|
|
26
|
+
let engine;
|
|
27
|
+
switch (provider) {
|
|
28
|
+
case 'claude':
|
|
29
|
+
engine = new ClaudeAgent({
|
|
30
|
+
model: model ?? defaultModels.claude,
|
|
31
|
+
reasoningEffort,
|
|
32
|
+
autoApprove,
|
|
33
|
+
logger,
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case 'codex':
|
|
37
|
+
engine = new CodexAgent({
|
|
38
|
+
model: model ?? defaultModels.codex,
|
|
39
|
+
reasoningEffort,
|
|
40
|
+
autoApprove,
|
|
41
|
+
logger,
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
default: {
|
|
45
|
+
// Reachable from untyped input that skipped `isAgentProvider`.
|
|
46
|
+
const unknownProvider = provider;
|
|
47
|
+
throw new InvalidAgentConfigError(`"${String(unknownProvider)}" is not an agent provider; expected one of: ${agentProviders.join(', ')}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return new RetryingAgent({ inner: engine, logger });
|
|
51
|
+
}
|
|
52
|
+
// A stronger model plans and reviews; a cheaper one executes the plan.
|
|
53
|
+
const orchestratorRoles = {
|
|
54
|
+
default: {
|
|
55
|
+
planner: { provider: 'codex', model: 'gpt-5.6-sol', reasoningEffort: 'high' },
|
|
56
|
+
executor: { provider: 'codex', model: 'gpt-5.6-luna', reasoningEffort: 'xhigh' },
|
|
57
|
+
reviewer: { provider: 'claude', model: 'opus', reasoningEffort: 'high' },
|
|
58
|
+
},
|
|
59
|
+
claude: {
|
|
60
|
+
planner: { provider: 'claude', model: 'opus', reasoningEffort: 'high' },
|
|
61
|
+
executor: { provider: 'claude', model: 'sonnet', reasoningEffort: 'xhigh' },
|
|
62
|
+
reviewer: { provider: 'claude', model: 'opus', reasoningEffort: 'high' },
|
|
63
|
+
},
|
|
64
|
+
codex: {
|
|
65
|
+
planner: { provider: 'codex', model: 'gpt-5.6-sol', reasoningEffort: 'high' },
|
|
66
|
+
executor: { provider: 'codex', model: 'gpt-5.6-luna', reasoningEffort: 'xhigh' },
|
|
67
|
+
reviewer: { provider: 'codex', model: 'gpt-5.6-sol', reasoningEffort: 'high' },
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Builds the planner → executor → reviewer workflow, each role an agent from `createAgent`.
|
|
72
|
+
*
|
|
73
|
+
* @throws {InvalidAgentConfigError} for an unknown provider.
|
|
74
|
+
* @throws {UnrecoverableError} when a Codex role cannot be set up, for example because its CLI
|
|
75
|
+
* binary is missing.
|
|
76
|
+
*/
|
|
77
|
+
export function createOrchestrator({ provider, autoApprove, logger = new Logger(), } = {}) {
|
|
78
|
+
if (provider !== undefined && !isAgentProvider(provider)) {
|
|
79
|
+
throw new InvalidAgentConfigError(`"${String(provider)}" is not an agent provider; expected one of: ${agentProviders.join(', ')}`);
|
|
80
|
+
}
|
|
81
|
+
const roles = orchestratorRoles[provider ?? 'default'];
|
|
82
|
+
const agentFor = ({ provider, model, reasoningEffort }) => createAgent(provider, { model, reasoningEffort, autoApprove, logger });
|
|
83
|
+
return new OrchestratorAgent({
|
|
84
|
+
plannerAgent: agentFor(roles.planner),
|
|
85
|
+
executorAgent: agentFor(roles.executor),
|
|
86
|
+
reviewerAgent: agentFor(roles.reviewer),
|
|
87
|
+
reviewerDecisionValidator: new ReviewerDecisionValidator(),
|
|
88
|
+
logger,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=agentFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentFactory.js","sourceRoot":"","sources":["../../../src/factory/infrastructure/agentFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,WAAW,GAGX,MAAM,0DAA0D,CAAC;AAClE,OAAO,EACN,UAAU,GAGV,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAC;AAClH,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,EAAE,MAAM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AC,IAAI,CAAC,EAAE,CAC/F,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,IAAI,SAAS,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAQ,EAAE,EAAE,CAC/D,WAAW,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IAExE,OAAO,IAAI,iBAAiB,CAAC;QAC5B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;QACrC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACvC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACvC,yBAAyB,EAAE,IAAI,yBAAyB,EAAE;QAC1D,MAAM;KACN,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Agent } from '../../agent/domain/agent.ts';\nimport { InvalidAgentConfigError } from '../../agent/domain/errors.ts';\nimport {\n\tClaudeAgent,\n\ttype ClaudeModel,\n\ttype ClaudeReasoningEffort,\n} from '../../engines/claude/infrastructure/model/claudeAgent.ts';\nimport {\n\tCodexAgent,\n\ttype CodexModel,\n\ttype CodexReasoningEffort,\n} from '../../engines/codex/infrastructure/model/codexAgent.ts';\nimport { OrchestratorAgent } from '../../orchestration/domain/model/orchestratorAgent.ts';\nimport { ReviewerDecisionValidator } from '../../orchestration/infrastructure/model/reviewerDecisionValidator.ts';\nimport { RetryingAgent } from '../../retry/domain/model/retryingAgent.ts';\nimport { isOneOf } from '../../shared/domain/isOneOf.ts';\nimport type { ILogger } from '../../shared/domain/logger.ts';\nimport { Logger } from '../../shared/infrastructure/logger.ts';\n\nexport const agentProviders = ['claude', 'codex'] as const;\nexport type AgentProvider = (typeof agentProviders)[number];\n\n/** Any provider's model. The engine the provider selects rejects one it does not support. */\nexport type AgentModel = ClaudeModel | CodexModel;\n/** Any provider's reasoning effort. The engine the provider selects rejects one it does not support. */\nexport type ReasoningEffort = ClaudeReasoningEffort | CodexReasoningEffort;\n\nexport function isAgentProvider(value: string): value is AgentProvider {\n\treturn isOneOf(agentProviders, value);\n}\n\nexport interface CreateAgentOptions {\n\t/** Defaults to `'opus'` on Claude and `'gpt-5.6-sol'` on Codex. */\n\tmodel?: AgentModel;\n\t/** Defaults to `'high'`. */\n\treasoningEffort?: ReasoningEffort;\n\t/** Maps to the provider's permission-bypass mode. Defaults to `false`. */\n\tautoApprove?: boolean;\n\t/** Defaults to warnings on stderr. */\n\tlogger?: ILogger;\n}\n\nconst defaultModels = {\n\tclaude: 'opus',\n\tcodex: 'gpt-5.6-sol',\n} as const satisfies Record<AgentProvider, AgentModel>;\n\n/**\n * Builds the agent for a provider, already wrapped in the harness's retry policy.\n *\n * @throws {InvalidAgentConfigError} for an unknown provider, or a model or reasoning effort\n * the provider does not support.\n * @throws {UnrecoverableError} when Codex cannot be set up, for example because its CLI binary\n * is missing.\n */\nexport function createAgent(\n\tprovider: AgentProvider,\n\t{ model, reasoningEffort, autoApprove, logger = new Logger() }: CreateAgentOptions = {},\n): Agent {\n\tlet engine: Agent;\n\n\tswitch (provider) {\n\t\tcase 'claude':\n\t\t\tengine = new ClaudeAgent({\n\t\t\t\tmodel: model ?? defaultModels.claude,\n\t\t\t\treasoningEffort,\n\t\t\t\tautoApprove,\n\t\t\t\tlogger,\n\t\t\t});\n\t\t\tbreak;\n\t\tcase 'codex':\n\t\t\tengine = new CodexAgent({\n\t\t\t\tmodel: model ?? defaultModels.codex,\n\t\t\t\treasoningEffort,\n\t\t\t\tautoApprove,\n\t\t\t\tlogger,\n\t\t\t});\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\t// Reachable from untyped input that skipped `isAgentProvider`.\n\t\t\tconst unknownProvider: never = provider;\n\t\t\tthrow new InvalidAgentConfigError(\n\t\t\t\t`\"${String(unknownProvider)}\" is not an agent provider; expected one of: ${agentProviders.join(', ')}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn new RetryingAgent({ inner: engine, logger });\n}\n\nexport interface CreateOrchestratorOptions {\n\t/**\n\t * Runs every role on one provider, for example when the other one is out of quota. By\n\t * default Codex plans and executes, and Claude reviews.\n\t */\n\tprovider?: AgentProvider;\n\t/** Maps to each provider's permission-bypass mode. Defaults to `false`. */\n\tautoApprove?: boolean;\n\t/** Defaults to warnings on stderr. */\n\tlogger?: ILogger;\n}\n\ninterface Role {\n\tprovider: AgentProvider;\n\tmodel: AgentModel;\n\treasoningEffort: ReasoningEffort;\n}\n\n// A stronger model plans and reviews; a cheaper one executes the plan.\nconst orchestratorRoles = {\n\tdefault: {\n\t\tplanner: { provider: 'codex', model: 'gpt-5.6-sol', reasoningEffort: 'high' },\n\t\texecutor: { provider: 'codex', model: 'gpt-5.6-luna', reasoningEffort: 'xhigh' },\n\t\treviewer: { provider: 'claude', model: 'opus', reasoningEffort: 'high' },\n\t},\n\tclaude: {\n\t\tplanner: { provider: 'claude', model: 'opus', reasoningEffort: 'high' },\n\t\texecutor: { provider: 'claude', model: 'sonnet', reasoningEffort: 'xhigh' },\n\t\treviewer: { provider: 'claude', model: 'opus', reasoningEffort: 'high' },\n\t},\n\tcodex: {\n\t\tplanner: { provider: 'codex', model: 'gpt-5.6-sol', reasoningEffort: 'high' },\n\t\texecutor: { provider: 'codex', model: 'gpt-5.6-luna', reasoningEffort: 'xhigh' },\n\t\treviewer: { provider: 'codex', model: 'gpt-5.6-sol', reasoningEffort: 'high' },\n\t},\n} as const satisfies Record<\n\tAgentProvider | 'default',\n\tRecord<'planner' | 'executor' | 'reviewer', Role>\n>;\n\n/**\n * Builds the planner → executor → reviewer workflow, each role an agent from `createAgent`.\n *\n * @throws {InvalidAgentConfigError} for an unknown provider.\n * @throws {UnrecoverableError} when a Codex role cannot be set up, for example because its CLI\n * binary is missing.\n */\nexport function createOrchestrator({\n\tprovider,\n\tautoApprove,\n\tlogger = new Logger(),\n}: CreateOrchestratorOptions = {}): Agent {\n\tif (provider !== undefined && !isAgentProvider(provider)) {\n\t\tthrow new InvalidAgentConfigError(\n\t\t\t`\"${String(provider)}\" is not an agent provider; expected one of: ${agentProviders.join(', ')}`,\n\t\t);\n\t}\n\n\tconst roles = orchestratorRoles[provider ?? 'default'];\n\tconst agentFor = ({ provider, model, reasoningEffort }: Role) =>\n\t\tcreateAgent(provider, { model, reasoningEffort, autoApprove, logger });\n\n\treturn new OrchestratorAgent({\n\t\tplannerAgent: agentFor(roles.planner),\n\t\texecutorAgent: agentFor(roles.executor),\n\t\treviewerAgent: agentFor(roles.reviewer),\n\t\treviewerDecisionValidator: new ReviewerDecisionValidator(),\n\t\tlogger,\n\t});\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
export type { ILogger } from './shared/domain/logger.ts';
|
|
2
|
-
export {
|
|
3
|
-
export { ClaudeAgent } from './engines/claude/infrastructure/model/claudeAgent.ts';
|
|
4
|
-
export { RetryingAgent } from './retry/domain/model/retryingAgent.ts';
|
|
5
|
-
export { OrchestratorAgent } from './orchestration/domain/model/orchestratorAgent.ts';
|
|
2
|
+
export { agentProviders, createAgent, createOrchestrator, isAgentProvider, type AgentModel, type AgentProvider, type CreateAgentOptions, type CreateOrchestratorOptions, type ReasoningEffort, } from './factory/infrastructure/agentFactory.ts';
|
|
6
3
|
export { type Agent, type AgentResponse, type Callback, type ProgressEvent, } from './agent/domain/agent.ts';
|
|
7
|
-
export { RecoverableError, UnrecoverableError } from './agent/domain/errors.ts';
|
|
4
|
+
export { InvalidAgentConfigError, RecoverableError, UnrecoverableError, } from './agent/domain/errors.ts';
|
|
8
5
|
export { isAbortError } from './shared/domain/isAbortError.ts';
|
|
9
|
-
export type { ReviewerDecision } from './orchestration/domain/model/reviewerDecision.ts';
|
|
10
|
-
export type { Validator } from './orchestration/domain/interface/validator.ts';
|
|
11
|
-
export { ReviewerDecisionValidator } from './orchestration/infrastructure/model/reviewerDecisionValidator.ts';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { ClaudeAgent } from "./engines/claude/infrastructure/model/claudeAgent.js";
|
|
3
|
-
export { RetryingAgent } from "./retry/domain/model/retryingAgent.js";
|
|
4
|
-
export { OrchestratorAgent } from "./orchestration/domain/model/orchestratorAgent.js";
|
|
1
|
+
export { agentProviders, createAgent, createOrchestrator, isAgentProvider, } from "./factory/infrastructure/agentFactory.js";
|
|
5
2
|
export {} from "./agent/domain/agent.js";
|
|
6
|
-
export { RecoverableError, UnrecoverableError } from "./agent/domain/errors.js";
|
|
3
|
+
export { InvalidAgentConfigError, RecoverableError, UnrecoverableError, } from "./agent/domain/errors.js";
|
|
7
4
|
export { isAbortError } from "./shared/domain/isAbortError.js";
|
|
8
|
-
export { ReviewerDecisionValidator } from "./orchestration/infrastructure/model/reviewerDecisionValidator.js";
|
|
9
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,eAAe,GAMf,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAKN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export type { ILogger } from './shared/domain/logger.ts';\nexport {\n\tagentProviders,\n\tcreateAgent,\n\tcreateOrchestrator,\n\tisAgentProvider,\n\ttype AgentModel,\n\ttype AgentProvider,\n\ttype CreateAgentOptions,\n\ttype CreateOrchestratorOptions,\n\ttype ReasoningEffort,\n} from './factory/infrastructure/agentFactory.ts';\nexport {\n\ttype Agent,\n\ttype AgentResponse,\n\ttype Callback,\n\ttype ProgressEvent,\n} from './agent/domain/agent.ts';\nexport {\n\tInvalidAgentConfigError,\n\tRecoverableError,\n\tUnrecoverableError,\n} from './agent/domain/errors.ts';\nexport { isAbortError } from './shared/domain/isAbortError.ts';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/orchestration/domain/interface/validator.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/orchestration/domain/interface/validator.ts"],"names":[],"mappings":"","sourcesContent":["export interface Validator<T> {\n\tvalidate(input: unknown): T | undefined;\n}\n"]}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import type { Agent, AgentResponse, Callback } from '../../../agent/domain/agent.ts';
|
|
2
2
|
import type { ReviewerDecision } from './reviewerDecision.ts';
|
|
3
3
|
import type { Validator } from '../interface/validator.ts';
|
|
4
|
+
import type { ILogger } from '../../../shared/domain/logger.ts';
|
|
4
5
|
export declare class OrchestratorAgent implements Agent {
|
|
5
6
|
private plannerAgent;
|
|
6
7
|
private executorAgent;
|
|
7
8
|
private reviewerAgent;
|
|
8
9
|
private reviewerDecisionValidator;
|
|
9
10
|
private maxAttempts;
|
|
10
|
-
|
|
11
|
+
private logger;
|
|
12
|
+
constructor({ plannerAgent, executorAgent, reviewerAgent, reviewerDecisionValidator, maxAttempts, logger, }: {
|
|
13
|
+
plannerAgent: Agent;
|
|
14
|
+
executorAgent: Agent;
|
|
15
|
+
reviewerAgent: Agent;
|
|
16
|
+
reviewerDecisionValidator: Validator<ReviewerDecision>;
|
|
17
|
+
maxAttempts?: number;
|
|
18
|
+
logger: ILogger;
|
|
19
|
+
});
|
|
11
20
|
run(prompt: string, signal: AbortSignal, callback: Callback): Promise<AgentResponse | undefined>;
|
|
12
21
|
private getReviewerDecision;
|
|
22
|
+
private warn;
|
|
13
23
|
}
|
|
14
|
-
//# sourceMappingURL=orchestratorAgent.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RecoverableError, UnrecoverableError } from "../../../agent/domain/errors.js";
|
|
2
|
+
import { classifyHostFailure, treatErrors } from "../../../agent/domain/providerFailure.js";
|
|
2
3
|
const getPlannerPrompt = (userPrompt, previousFailureReason) => {
|
|
3
4
|
const feedback = previousFailureReason
|
|
4
5
|
? `\n\nFeedback from the previous attempt:\n---\n${previousFailureReason}\n---`
|
|
@@ -80,7 +81,8 @@ export class OrchestratorAgent {
|
|
|
80
81
|
reviewerAgent;
|
|
81
82
|
reviewerDecisionValidator;
|
|
82
83
|
maxAttempts;
|
|
83
|
-
|
|
84
|
+
logger;
|
|
85
|
+
constructor({ plannerAgent, executorAgent, reviewerAgent, reviewerDecisionValidator, maxAttempts = 3, logger, }) {
|
|
84
86
|
if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {
|
|
85
87
|
throw new RangeError('maxAttempts must be a positive integer');
|
|
86
88
|
}
|
|
@@ -89,6 +91,7 @@ export class OrchestratorAgent {
|
|
|
89
91
|
this.reviewerAgent = reviewerAgent;
|
|
90
92
|
this.reviewerDecisionValidator = reviewerDecisionValidator;
|
|
91
93
|
this.maxAttempts = maxAttempts;
|
|
94
|
+
this.logger = logger;
|
|
92
95
|
}
|
|
93
96
|
async run(prompt, signal, callback) {
|
|
94
97
|
// Per invocation, not per instance: the CLI keeps one orchestrator for a whole session.
|
|
@@ -102,6 +105,7 @@ export class OrchestratorAgent {
|
|
|
102
105
|
if (isLastAttempt) {
|
|
103
106
|
throw new UnrecoverableError('Max attempts exhausted', { cause: lastFailureReason });
|
|
104
107
|
}
|
|
108
|
+
this.warn(`Attempt ${String(attempt)}/${String(this.maxAttempts)}: the planner produced no response; starting another round`);
|
|
105
109
|
continue;
|
|
106
110
|
}
|
|
107
111
|
addToTotals(totals, plannerResponse);
|
|
@@ -111,6 +115,7 @@ export class OrchestratorAgent {
|
|
|
111
115
|
if (isLastAttempt) {
|
|
112
116
|
throw new UnrecoverableError('Max attempts exhausted', { cause: lastFailureReason });
|
|
113
117
|
}
|
|
118
|
+
this.warn(`Attempt ${String(attempt)}/${String(this.maxAttempts)}: the executor produced no response; starting another round`);
|
|
114
119
|
continue;
|
|
115
120
|
}
|
|
116
121
|
addToTotals(totals, executorResponse);
|
|
@@ -122,6 +127,7 @@ export class OrchestratorAgent {
|
|
|
122
127
|
if (isLastAttempt) {
|
|
123
128
|
throw new UnrecoverableError('Max attempts exhausted', { cause: lastFailureReason });
|
|
124
129
|
}
|
|
130
|
+
this.warn(`Attempt ${String(attempt)}/${String(this.maxAttempts)}: the reviewer rejected the round; starting another with its feedback`, lastFailureReason);
|
|
125
131
|
}
|
|
126
132
|
throw new UnrecoverableError('Max attempts exhausted', {
|
|
127
133
|
cause: lastFailureReason ?? 'Unknown failure.',
|
|
@@ -147,11 +153,17 @@ export class OrchestratorAgent {
|
|
|
147
153
|
if (attempt === this.maxAttempts) {
|
|
148
154
|
throw new UnrecoverableError('Max attempts exhausted', { cause: parseFailureReason });
|
|
149
155
|
}
|
|
156
|
+
this.warn(`Reviewer decision ${String(attempt)}/${String(this.maxAttempts)} was unusable; asking the reviewer again`, parseFailureReason);
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
159
|
throw new UnrecoverableError('Max attempts exhausted', {
|
|
153
160
|
cause: parseFailureReason ?? 'Unknown failure.',
|
|
154
161
|
});
|
|
155
162
|
}
|
|
163
|
+
warn(...args) {
|
|
164
|
+
treatErrors(() => {
|
|
165
|
+
this.logger.warn(...args);
|
|
166
|
+
}, classifyHostFailure, 'Orchestrator logger failed while reporting a retry');
|
|
167
|
+
}
|
|
156
168
|
}
|
|
157
169
|
//# sourceMappingURL=orchestratorAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestratorAgent.js","s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;YACvC,CAAC;YAED,IAAI,CAAC;gBACJ,OAAO,qBAAqB,CAAC,gBAAgB,EAAE,IAAI,CAAC,yBAAyB,CAAC,CAAC;YAChF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC;oBAAE,MAAM,KAAK,CAAC;gBAEtD,kBAAkB,GAAG,KAAK,CAAC,KAAK,CAAC;gBACjC,IAAI,OAAO,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;oBAClC,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;gBACvF,CAAC;YACF,CAAC;QACF,CAAC;QAED,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,EAAE;YACtD,KAAK,EAAE,kBAAkB,IAAI,kBAAkB;SAC/C,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"orchestratorAgent.js","sourceRoot":"","sources":["../../../../src/orchestration/domain/model/orchestratorAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIvF,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5F,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAE,qBAA8B,EAAE,EAAE;IAC/E,MAAM,QAAQ,GAAG,qBAAqB;QACrC,CAAC,CAAC,iDAAiD,qBAAqB,OAAO;QAC/E,CAAC,CAAC,EAAE,CAAC;IAEN,OAAO;;;;EAIN,UAAU;KACP,QAAQ,EAAE,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,UAAkB,EAAE,aAAqB,EAAE,EAAE,CACvE;;;;EAIC,UAAU;;;;;EAKV,aAAa;IACX,CAAC;AAEL,MAAM,iBAAiB,GAAG,CACzB,UAAkB,EAClB,aAAqB,EACrB,cA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AAC,CAAC;YAChF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC;oBAAE,MAAM,KAAK,CAAC;gBAEtD,kBAAkB,GAAG,KAAK,CAAC,KAAK,CAAC;gBACjC,IAAI,OAAO,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;oBAClC,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;gBACvF,CAAC;gBAED,IAAI,CAAC,IAAI,CACR,qBAAqB,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,0CAA0C,EAC1G,kBAAkB,CAClB,CAAC;YACH,CAAC;QACF,CAAC;QAED,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,EAAE;YACtD,KAAK,EAAE,kBAAkB,IAAI,kBAAkB;SAC/C,CAAC,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,GAAG,IAAe;QAC9B,WAAW,CACV,GAAG,EAAE;YACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,EACD,mBAAmB,EACnB,oDAAoD,CACpD,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Agent, AgentResponse, Callback } from '../../../agent/domain/agent.ts';\nimport { RecoverableError, UnrecoverableError } from '../../../agent/domain/errors.ts';\nimport type { ReviewerDecision } from './reviewerDecision.ts';\nimport type { Validator } from '../interface/validator.ts';\nimport type { ILogger } from '../../../shared/domain/logger.ts';\nimport { classifyHostFailure, treatErrors } from '../../../agent/domain/providerFailure.ts';\n\nconst getPlannerPrompt = (userPrompt: string, previousFailureReason?: string) => {\n\tconst feedback = previousFailureReason\n\t\t? `\\n\\nFeedback from the previous attempt:\\n---\\n${previousFailureReason}\\n---`\n\t\t: '';\n\n\treturn `You are the planner agent. Read the relevant repository code and create a concise, engineering-grade plan for the executor. Cover the requested behaviour, structural issues, affected files or symbols, API contracts and boundaries, important failure paths, and meaningful tests. Keep the plan focused on the current request and do not require an architecture redesign yet.\n\nOriginal user request:\n---\n${userPrompt}\n---${feedback}`;\n};\n\nconst getExecutorPrompt = (userPrompt: string, plannerPrompt: string) =>\n\t`You are the executor agent. Read the relevant repository code and implement the original user request according to the planner's current plan. Preserve contracts and boundaries, handle important failure paths, keep the change focused, and add or update meaningful tests. Inspect and change the code; do not merely describe what should be done.\n\nOriginal user request:\n---\n${userPrompt}\n---\n\nCurrent implementation plan:\n---\n${plannerPrompt}\n---`;\n\nconst getReviewerPrompt = (\n\tuserPrompt: string,\n\tplannerPrompt: string,\n\texecutorResult: string,\n\tparseFailureReason?: string,\n) => {\n\tconst retryNotice = parseFailureReason\n\t\t? `\\n\\nYour previous response could not be used: ${parseFailureReason} Respond with JSON only, matching the schema exactly, with no surrounding text and no markdown code fences.`\n\t\t: '';\n\n\treturn `You are the reviewer agent. Independently inspect the repository, the current diff, and relevant surrounding code; do not rely on the executor's narrative. Evaluate the original request first; plan compliance is secondary and provides supporting context. Check correctness and logic errors, important failure paths, unused or artificial abstractions, races or shared state, API contract breaks, boundary violations, regressions, scope, and test quality. If it is correct, respond with JSON only: {\"decision\":\"approved\"}. If it is not correct, respond with JSON only: {\"decision\":\"rejected\",\"feedback\":\"list concrete, prioritized findings and the required direction for each\"}. The feedback must contain actionable engineering findings, not a general summary.\n\nOriginal user request:\n---\n${userPrompt}\n---\n\nPlanner's current plan:\n---\n${plannerPrompt}\n---\n\nExecutor response (context only; verify it independently):\n---\n${executorResult}\n---${retryNotice}`;\n};\n\ninterface RunTotals {\n\tduration: number;\n\tinputTokens: number;\n\toutputTokens: number;\n}\n\nfunction addToTotals(totals: RunTotals, response: AgentResponse): void {\n\ttotals.duration += response.duration;\n\ttotals.inputTokens += response.inputTokens;\n\ttotals.outputTokens += response.outputTokens;\n}\n\nfunction stripCodeFence(text: string): string {\n\tconst match = /^```(?:json)?\\s*([\\s\\S]*?)\\s*```$/.exec(text.trim());\n\treturn match?.[1] ?? text;\n}\n\nfunction parseReviewerDecision(\n\tresponse: AgentResponse | undefined,\n\treviewerDecisionValidator: Validator<ReviewerDecision>,\n): ReviewerDecision {\n\tif (!response?.response) {\n\t\tthrow new RecoverableError(\"There's no decision from the reviewer, something went wrong\", {\n\t\t\tcause: 'Reviewer decision is missing.',\n\t\t});\n\t}\n\n\tlet parsedResponse: unknown;\n\ttry {\n\t\tparsedResponse = JSON.parse(stripCodeFence(response.response));\n\t} catch {\n\t\tthrow new RecoverableError('Reviewer returned an invalid decision', {\n\t\t\tcause: 'Reviewer response must be valid JSON.',\n\t\t});\n\t}\n\n\tconst decision = reviewerDecisionValidator.validate(parsedResponse);\n\tif (!decision) {\n\t\tthrow new RecoverableError('Reviewer returned an invalid decision', {\n\t\t\tcause: 'Reviewer response did not match the decision schema.',\n\t\t});\n\t}\n\n\treturn decision;\n}\n\nexport class OrchestratorAgent implements Agent {\n\tprivate plannerAgent: Agent;\n\tprivate executorAgent: Agent;\n\tprivate reviewerAgent: Agent;\n\tprivate reviewerDecisionValidator: Validator<ReviewerDecision>;\n\tprivate maxAttempts: number;\n\tprivate logger: ILogger;\n\n\tconstructor({\n\t\tplannerAgent,\n\t\texecutorAgent,\n\t\treviewerAgent,\n\t\treviewerDecisionValidator,\n\t\tmaxAttempts = 3,\n\t\tlogger,\n\t}: {\n\t\tplannerAgent: Agent;\n\t\texecutorAgent: Agent;\n\t\treviewerAgent: Agent;\n\t\treviewerDecisionValidator: Validator<ReviewerDecision>;\n\t\tmaxAttempts?: number;\n\t\tlogger: ILogger;\n\t}) {\n\t\tif (!Number.isInteger(maxAttempts) || maxAttempts < 1) {\n\t\t\tthrow new RangeError('maxAttempts must be a positive integer');\n\t\t}\n\n\t\tthis.plannerAgent = plannerAgent;\n\t\tthis.executorAgent = executorAgent;\n\t\tthis.reviewerAgent = reviewerAgent;\n\t\tthis.reviewerDecisionValidator = reviewerDecisionValidator;\n\t\tthis.maxAttempts = maxAttempts;\n\t\tthis.logger = logger;\n\t}\n\n\tasync run(\n\t\tprompt: string,\n\t\tsignal: AbortSignal,\n\t\tcallback: Callback,\n\t): Promise<AgentResponse | undefined> {\n\t\t// Per invocation, not per instance: the CLI keeps one orchestrator for a whole session.\n\t\tconst totals: RunTotals = { duration: 0, inputTokens: 0, outputTokens: 0 };\n\t\tlet lastFailureReason: string | undefined;\n\n\t\tfor (let attempt = 1; attempt <= this.maxAttempts; attempt++) {\n\t\t\tconst isLastAttempt = attempt === this.maxAttempts;\n\n\t\t\tconst plannerResponse = await this.plannerAgent.run(\n\t\t\t\tgetPlannerPrompt(prompt, lastFailureReason),\n\t\t\t\tsignal,\n\t\t\t\tcallback,\n\t\t\t);\n\n\t\t\tif (!plannerResponse?.response) {\n\t\t\t\tlastFailureReason = 'The planner produced no response.';\n\t\t\t\tif (isLastAttempt) {\n\t\t\t\t\tthrow new UnrecoverableError('Max attempts exhausted', { cause: lastFailureReason });\n\t\t\t\t}\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Attempt ${String(attempt)}/${String(this.maxAttempts)}: the planner produced no response; starting another round`,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\taddToTotals(totals, plannerResponse);\n\n\t\t\tconst executorResponse = await this.executorAgent.run(\n\t\t\t\tgetExecutorPrompt(prompt, plannerResponse.response),\n\t\t\t\tsignal,\n\t\t\t\tcallback,\n\t\t\t);\n\n\t\t\tif (!executorResponse?.response) {\n\t\t\t\tlastFailureReason = 'The executor produced no response.';\n\t\t\t\tif (isLastAttempt) {\n\t\t\t\t\tthrow new UnrecoverableError('Max attempts exhausted', { cause: lastFailureReason });\n\t\t\t\t}\n\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Attempt ${String(attempt)}/${String(this.maxAttempts)}: the executor produced no response; starting another round`,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\taddToTotals(totals, executorResponse);\n\n\t\t\tconst reviewerDecision = await this.getReviewerDecision(\n\t\t\t\tprompt,\n\t\t\t\tplannerResponse.response,\n\t\t\t\texecutorResponse.response,\n\t\t\t\tsignal,\n\t\t\t\tcallback,\n\t\t\t\ttotals,\n\t\t\t);\n\n\t\t\tif (reviewerDecision.decision === 'approved') {\n\t\t\t\treturn { response: 'All job has finished', ...totals };\n\t\t\t}\n\n\t\t\tlastFailureReason = reviewerDecision.feedback;\n\t\t\tif (isLastAttempt) {\n\t\t\t\tthrow new UnrecoverableError('Max attempts exhausted', { cause: lastFailureReason });\n\t\t\t}\n\n\t\t\tthis.warn(\n\t\t\t\t`Attempt ${String(attempt)}/${String(this.maxAttempts)}: the reviewer rejected the round; starting another with its feedback`,\n\t\t\t\tlastFailureReason,\n\t\t\t);\n\t\t}\n\n\t\tthrow new UnrecoverableError('Max attempts exhausted', {\n\t\t\tcause: lastFailureReason ?? 'Unknown failure.',\n\t\t});\n\t}\n\n\t// Retries only the reviewer call on a malformed decision, instead of redoing\n\t// planning/execution — a bad or unparsable reviewer response is not evidence\n\t// the plan or the implementation were wrong.\n\tprivate async getReviewerDecision(\n\t\tuserPrompt: string,\n\t\tplannerPrompt: string,\n\t\texecutorResult: string,\n\t\tsignal: AbortSignal,\n\t\tcallback: Callback,\n\t\ttotals: RunTotals,\n\t): Promise<ReviewerDecision> {\n\t\tlet parseFailureReason: string | undefined;\n\n\t\tfor (let attempt = 1; attempt <= this.maxAttempts; attempt++) {\n\t\t\tconst reviewerResponse = await this.reviewerAgent.run(\n\t\t\t\tgetReviewerPrompt(userPrompt, plannerPrompt, executorResult, parseFailureReason),\n\t\t\t\tsignal,\n\t\t\t\tcallback,\n\t\t\t);\n\n\t\t\tif (reviewerResponse) {\n\t\t\t\taddToTotals(totals, reviewerResponse);\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\treturn parseReviewerDecision(reviewerResponse, this.reviewerDecisionValidator);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof RecoverableError)) throw error;\n\n\t\t\t\tparseFailureReason = error.cause;\n\t\t\t\tif (attempt === this.maxAttempts) {\n\t\t\t\t\tthrow new UnrecoverableError('Max attempts exhausted', { cause: parseFailureReason });\n\t\t\t\t}\n\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Reviewer decision ${String(attempt)}/${String(this.maxAttempts)} was unusable; asking the reviewer again`,\n\t\t\t\t\tparseFailureReason,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthrow new UnrecoverableError('Max attempts exhausted', {\n\t\t\tcause: parseFailureReason ?? 'Unknown failure.',\n\t\t});\n\t}\n\n\tprivate warn(...args: unknown[]): void {\n\t\ttreatErrors(\n\t\t\t() => {\n\t\t\t\tthis.logger.warn(...args);\n\t\t\t},\n\t\t\tclassifyHostFailure,\n\t\t\t'Orchestrator logger failed while reporting a retry',\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewerDecision.js","sourceRoot":"","sources":["../../../../src/orchestration/domain/model/reviewerDecision.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"reviewerDecision.js","sourceRoot":"","sources":["../../../../src/orchestration/domain/model/reviewerDecision.ts"],"names":[],"mappings":"","sourcesContent":["export type ReviewerDecision =\n\t{ decision: 'approved' } | { decision: 'rejected'; feedback: string };\n"]}
|
|
@@ -3,4 +3,3 @@ import type { ReviewerDecision } from '../../domain/model/reviewerDecision.ts';
|
|
|
3
3
|
export declare class ReviewerDecisionValidator implements Validator<ReviewerDecision> {
|
|
4
4
|
validate(input: unknown): ReviewerDecision | undefined;
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=reviewerDecisionValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewerDecisionValidator.js","sourceRoot":"","sources":["../../../../src/orchestration/infrastructure/model/reviewerDecisionValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACjD,CAAC;CACD","sourcesContent":["import { z } from 'zod';\nimport type { Validator } from '../../domain/interface/validator.ts';\nimport type { ReviewerDecision } from '../../domain/model/reviewerDecision.ts';\n\nconst reviewerDecisionSchema = z.discriminatedUnion('decision', [\n\tz.object({ decision: z.literal('approved') }),\n\tz.object({ decision: z.literal('rejected'), feedback: z.string().trim().min(1) }),\n]);\n\nexport class ReviewerDecisionValidator implements Validator<ReviewerDecision> {\n\tvalidate(input: unknown): ReviewerDecision | undefined {\n\t\tconst result = reviewerDecisionSchema.safeParse(input);\n\t\treturn result.success ? result.data : undefined;\n\t}\n}\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Agent, AgentResponse, Callback } from '../../../agent/domain/agent.ts';
|
|
2
|
+
import type { ILogger } from '../../../shared/domain/logger.ts';
|
|
2
3
|
export declare class RetryingAgent implements Agent {
|
|
3
4
|
private inner;
|
|
4
5
|
private maxAttempts;
|
|
5
|
-
|
|
6
|
+
private logger;
|
|
7
|
+
constructor({ inner, maxAttempts, logger, }: {
|
|
8
|
+
inner: Agent;
|
|
9
|
+
maxAttempts?: number;
|
|
10
|
+
logger: ILogger;
|
|
11
|
+
});
|
|
6
12
|
run(prompt: string, signal: AbortSignal, callback: Callback): Promise<AgentResponse | undefined>;
|
|
7
13
|
}
|
|
8
|
-
//# sourceMappingURL=retryingAgent.d.ts.map
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { RecoverableError, UnrecoverableError } from "../../../agent/domain/errors.js";
|
|
2
|
-
import { describeFailure } from "../../../agent/domain/providerFailure.js";
|
|
2
|
+
import { classifyHostFailure, describeFailure, treatErrors, } from "../../../agent/domain/providerFailure.js";
|
|
3
3
|
import { isAbortError } from "../../../shared/domain/isAbortError.js";
|
|
4
4
|
export class RetryingAgent {
|
|
5
5
|
inner;
|
|
6
6
|
maxAttempts;
|
|
7
|
-
|
|
7
|
+
logger;
|
|
8
|
+
constructor({ inner, maxAttempts = 3, logger, }) {
|
|
9
|
+
if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {
|
|
10
|
+
throw new RangeError('maxAttempts must be a positive integer');
|
|
11
|
+
}
|
|
8
12
|
this.inner = inner;
|
|
9
13
|
this.maxAttempts = maxAttempts;
|
|
14
|
+
this.logger = logger;
|
|
10
15
|
}
|
|
11
16
|
async run(prompt, signal, callback) {
|
|
12
17
|
let lastPrompt = null;
|
|
@@ -29,7 +34,12 @@ export class RetryingAgent {
|
|
|
29
34
|
throw new UnrecoverableError('Max attempts exhausted', {
|
|
30
35
|
cause: `Gave up after ${String(this.maxAttempts)} attempts. Last failure: ${e.cause}`,
|
|
31
36
|
});
|
|
32
|
-
|
|
37
|
+
// Keeps the original request: an attempt that failed before the provider registered
|
|
38
|
+
// the turn left no session that remembers it.
|
|
39
|
+
lastPrompt = `${prompt}\n\nThe previous attempt failed for the following reason: ${e.cause}`;
|
|
40
|
+
treatErrors(() => {
|
|
41
|
+
this.logger.warn(`Attempt ${String(attempt)}/${String(this.maxAttempts)} failed; retrying`, e);
|
|
42
|
+
}, classifyHostFailure, 'RetryingAgent logger failed while reporting a retry');
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryingAgent.js","sourceRoot":"","sources":["../../../../src/retry/domain/model/retryingAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,
|
|
1
|
+
{"version":3,"file":"retryingAgent.js","sourceRoot":"","sources":["../../../../src/retry/domain/model/retryingAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACvF,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CAAC,CAAC;qBACzB,CAAC,CAAC;gBAEJ,IAAI,OAAO,KAAK,IAAI,CAAC,WAAW;oBAC/B,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,EAAE;wBACtD,KAAK,EAAE,iBAAiB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC,KAAK,EAAE;qBACrF,CAAC,CAAC;gBAEJ,oFAAoF;gBACpF,8CAA8C;gBAC9C,UAAU,GAAG,GAAG,MAAM,6DAA6D,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC7F,WAAW,CACV,GAAG,EAAE;oBACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CACf,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EACzE,CAAC,CACD,CAAC;gBACH,CAAC,EACD,mBAAmB,EACnB,qDAAqD,CACrD,CAAC;YACH,CAAC;QACF,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD","sourcesContent":["import type { Agent, AgentResponse, Callback } from '../../../agent/domain/agent.ts';\nimport { RecoverableError, UnrecoverableError } from '../../../agent/domain/errors.ts';\nimport {\n\tclassifyHostFailure,\n\tdescribeFailure,\n\ttreatErrors,\n} from '../../../agent/domain/providerFailure.ts';\nimport { isAbortError } from '../../../shared/domain/isAbortError.ts';\nimport type { ILogger } from '../../../shared/domain/logger.ts';\n\nexport class RetryingAgent implements Agent {\n\tprivate inner: Agent;\n\tprivate maxAttempts: number;\n\tprivate logger: ILogger;\n\n\tconstructor({\n\t\tinner,\n\t\tmaxAttempts = 3,\n\t\tlogger,\n\t}: {\n\t\tinner: Agent;\n\t\tmaxAttempts?: number;\n\t\tlogger: ILogger;\n\t}) {\n\t\tif (!Number.isInteger(maxAttempts) || maxAttempts < 1) {\n\t\t\tthrow new RangeError('maxAttempts must be a positive integer');\n\t\t}\n\n\t\tthis.inner = inner;\n\t\tthis.maxAttempts = maxAttempts;\n\t\tthis.logger = logger;\n\t}\n\n\tasync run(\n\t\tprompt: string,\n\t\tsignal: AbortSignal,\n\t\tcallback: Callback,\n\t): Promise<AgentResponse | undefined> {\n\t\tlet lastPrompt: string | null = null;\n\t\tfor (let attempt = 1; attempt <= this.maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\tconst promptToSend = lastPrompt ?? prompt;\n\t\t\t\treturn await this.inner.run(promptToSend, signal, callback);\n\t\t\t} catch (e) {\n\t\t\t\tif (isAbortError(e) || e instanceof UnrecoverableError) throw e;\n\n\t\t\t\t// Only a failure the agent classified as recoverable earns another call. An\n\t\t\t\t// unclassified one breaks the `Agent` contract, so nothing here knows whether\n\t\t\t\t// replaying it is safe — it may already have written files or run commands.\n\t\t\t\tif (!(e instanceof RecoverableError))\n\t\t\t\t\tthrow new UnrecoverableError('The agent failed without classifying the failure', {\n\t\t\t\t\t\tcause: describeFailure(e),\n\t\t\t\t\t});\n\n\t\t\t\tif (attempt === this.maxAttempts)\n\t\t\t\t\tthrow new UnrecoverableError('Max attempts exhausted', {\n\t\t\t\t\t\tcause: `Gave up after ${String(this.maxAttempts)} attempts. Last failure: ${e.cause}`,\n\t\t\t\t\t});\n\n\t\t\t\t// Keeps the original request: an attempt that failed before the provider registered\n\t\t\t\t// the turn left no session that remembers it.\n\t\t\t\tlastPrompt = `${prompt}\\n\\nThe previous attempt failed for the following reason: ${e.cause}`;\n\t\t\t\ttreatErrors(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Attempt ${String(attempt)}/${String(this.maxAttempts)} failed; retrying`,\n\t\t\t\t\t\t\te,\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tclassifyHostFailure,\n\t\t\t\t\t'RetryingAgent logger failed while reporting a retry',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAbortError.js","sourceRoot":"","sources":["../../../src/shared/domain/isAbortError.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,CAAU;IACtC,OAAO,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;AACtD,CAAC"}
|
|
1
|
+
{"version":3,"file":"isAbortError.js","sourceRoot":"","sources":["../../../src/shared/domain/isAbortError.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,CAAU;IACtC,OAAO,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;AACtD,CAAC","sourcesContent":["export function isAbortError(e: unknown): e is Error {\n\treturn e instanceof Error && e.name === 'AbortError';\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isOneOf.js","sourceRoot":"","sources":["../../../src/shared/domain/isOneOf.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,UAAU,OAAO,CAAmB,MAAoB,EAAE,KAAa;IAC5E,OAAQ,MAA4B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC","sourcesContent":["/** Narrows untyped input, such as a CLI flag, to one of a fixed set of string literals. */\nexport function isOneOf<T extends string>(values: readonly T[], value: string): value is T {\n\treturn (values as readonly string[]).includes(value);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/shared/domain/logger.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/shared/domain/logger.ts"],"names":[],"mappings":"","sourcesContent":["export interface ILogger {\n\twarn: (...args: unknown[]) => void;\n}\n"]}
|