@mikode13/harness 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +5 -0
  2. package/dist/agent/domain/agent.d.ts +1 -1
  3. package/dist/agent/domain/agent.js.map +1 -1
  4. package/dist/agent/domain/errors.d.ts +1 -1
  5. package/dist/agent/domain/errors.js +1 -1
  6. package/dist/agent/domain/errors.js.map +1 -1
  7. package/dist/agent/domain/providerFailure.js +1 -1
  8. package/dist/agent/domain/providerFailure.js.map +1 -1
  9. package/dist/engines/claude/infrastructure/model/claudeAgent.d.ts +2 -2
  10. package/dist/engines/claude/infrastructure/model/claudeAgent.js +3 -3
  11. package/dist/engines/claude/infrastructure/model/claudeAgent.js.map +1 -1
  12. package/dist/engines/codex/infrastructure/model/codexAgent.d.ts +2 -2
  13. package/dist/engines/codex/infrastructure/model/codexAgent.js +4 -4
  14. package/dist/engines/codex/infrastructure/model/codexAgent.js.map +1 -1
  15. package/dist/engines/domain/model/llmAgent.d.ts +3 -3
  16. package/dist/engines/domain/model/llmAgent.js +3 -3
  17. package/dist/engines/domain/model/llmAgent.js.map +1 -1
  18. package/dist/factory/infrastructure/agentFactory.d.ts +19 -13
  19. package/dist/factory/infrastructure/agentFactory.js +48 -23
  20. package/dist/factory/infrastructure/agentFactory.js.map +1 -1
  21. package/dist/llm/domain/errors.d.ts +1 -1
  22. package/dist/llm/domain/errors.js +1 -1
  23. package/dist/llm/domain/errors.js.map +1 -1
  24. package/dist/llm/domain/llm.d.ts +1 -1
  25. package/dist/llm/domain/llm.js.map +1 -1
  26. package/dist/llm/infrastructure/claudeLLMClient.d.ts +21 -0
  27. package/dist/llm/infrastructure/claudeLLMClient.js +189 -0
  28. package/dist/llm/infrastructure/claudeLLMClient.js.map +1 -0
  29. package/dist/llm/infrastructure/openAILLMClient.d.ts +1 -1
  30. package/dist/llm/infrastructure/openAILLMClient.js +4 -4
  31. package/dist/llm/infrastructure/openAILLMClient.js.map +1 -1
  32. package/dist/orchestration/domain/model/orchestratorAgent.d.ts +2 -2
  33. package/dist/orchestration/domain/model/orchestratorAgent.js +3 -3
  34. package/dist/orchestration/domain/model/orchestratorAgent.js.map +1 -1
  35. package/dist/retry/domain/model/retryingAgent.d.ts +2 -2
  36. package/dist/retry/domain/model/retryingAgent.js +4 -4
  37. package/dist/retry/domain/model/retryingAgent.js.map +1 -1
  38. package/package.json +8 -2
@@ -1 +1 @@
1
- {"version":3,"file":"retryingAgent.js","sourceRoot":"","sources":["../../../../src/retry/domain/model/retryingAgent.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,WAAW,GACX,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAe,MAAM,kCAAkC,CAAC;AAE1E,MAAM,OAAO,aAAa;IACjB,KAAK,CAAQ;IACb,WAAW,CAAS;IACpB,MAAM,CAAU;IAChB,YAAY,CAAU;IAE9B,YAAY,EACX,KAAK,EACL,WAAW,GAAG,CAAC,EACf,MAAM,EACN,YAAY,GAAG,IAAI,GAYnB;QACA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACvD,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,MAAmB,EAAE,QAAkB;QAChE,MAAM,K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CAAC,CAAC,MAAM,CAAC,CAAC;gBACnC,UAAU,KAAK,CAAC,CAAC,eAAe,CAAC;gBAEjC,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;wBACrF,MAAM,EAAE,KAAK;wBACb,eAAe,EAAE,UAAU;qBAC3B,CAAC,CAAC;gBAEJ,oFAAoF;gBACpF,8CAA8C;gBAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACvB,UAAU,GAAG,GAAG,MAAM,6DAA6D,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC9F,CAAC;gBACD,IAAI,CAAC;oBACJ,WAAW,CACV,GAAG,EAAE;wBACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CACf,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EACzE,CAAC,CACD,CAAC;oBACH,CAAC,EACD,mBAAmB,EACnB,qDAAqD,CACrD,CAAC;gBACH,CAAC;gBAAC,OAAO,UAAU,EAAE,CAAC;oBACrB,oEAAoE;oBACpE,MAAM,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;gBACtD,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { Agent, AgentResponse, Callback } from '../../../agent/domain/agent.ts';\nimport {\n\tRecoverableError,\n\tUnrecoverableError,\n\twithSpentTokens,\n} 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';\nimport { addTokens, type Tokens } from '../../../shared/domain/tokens.ts';\n\nexport class RetryingAgent implements Agent {\n\tprivate inner: Agent;\n\tprivate maxAttempts: number;\n\tprivate logger: ILogger;\n\tprivate noteFailures: boolean;\n\n\tconstructor({\n\t\tinner,\n\t\tmaxAttempts = 3,\n\t\tlogger,\n\t\tnoteFailures = true,\n\t}: {\n\t\tinner: Agent;\n\t\tmaxAttempts?: number;\n\t\tlogger: ILogger;\n\t\t/**\n\t\t * Appends the previous failure to the retried prompt, so a provider session that may\n\t\t * remember the failed turn is told what happened. Off for an agent that records nothing\n\t\t * from a failed call, such as `LLMAgent`: there the note would become a permanent user\n\t\t * message resent on every later turn.\n\t\t */\n\t\tnoteFailures?: boolean;\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\tthis.noteFailures = noteFailures;\n\t}\n\n\tasync run(prompt: string, signal: AbortSignal, callback: Callback): Promise<AgentResponse> {\n\t\tconst start = Date.now();\n\t\tlet lastPrompt: string | null = null;\n\t\t// Failed attempts were billed too, so they travel with whichever way the run ends.\n\t\tlet spent: Tokens | undefined;\n\t\t// An attempt was answered without usage, so `spent` is only a subtotal.\n\t\tlet unreported = false;\n\n\t\tfor (let attempt = 1; ; attempt++) {\n\t\t\ttry {\n\t\t\t\tconst promptToSend = lastPrompt ?? prompt;\n\t\t\t\tconst response = await this.inner.run(promptToSend, signal, callback);\n\t\t\t\treturn {\n\t\t\t\t\t...response,\n\t\t\t\t\t// Any call answered without usage makes the whole count unknown, not partial.\n\t\t\t\t\ttokens: unreported ? undefined : response.tokens && addTokens(spent, response.tokens),\n\t\t\t\t\t// Every attempt was waited for, not only the last one.\n\t\t\t\t\tduration: (Date.now() - start) / 1000,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\tif (isAbortError(e)) throw e;\n\t\t\t\tif (e instanceof UnrecoverableError) throw withSpentTokens(e, spent, unreported);\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\ttokens: spent,\n\t\t\t\t\t\tusageUnreported: unreported,\n\t\t\t\t\t});\n\n\t\t\t\tspent = addTokens(spent, e.tokens);\n\t\t\t\tunreported ||= e.usageUnreported;\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\ttokens: spent,\n\t\t\t\t\t\tusageUnreported: unreported,\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\tif (this.noteFailures) {\n\t\t\t\t\tlastPrompt = `${prompt}\\n\\nThe previous attempt failed for the following reason: ${e.cause}`;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\ttreatErrors(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t\t`Attempt ${String(attempt)}/${String(this.maxAttempts)} failed; retrying`,\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tclassifyHostFailure,\n\t\t\t\t\t\t'RetryingAgent logger failed while reporting a retry',\n\t\t\t\t\t);\n\t\t\t\t} catch (logFailure) {\n\t\t\t\t\t// The attempts already spent their tokens, whatever the logger did.\n\t\t\t\t\tthrow withSpentTokens(logFailure, spent, unreported);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"retryingAgent.js","sourceRoot":"","sources":["../../../../src/retry/domain/model/retryingAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,WAAW,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAe,MAAM,2BAA2B,CAAC;AAEnE,MAAM,OAAO,aAAa;IACjB,KAAK,CAAQ;IACb,WAAW,CAAS;IACpB,MAAM,CAAU;IAChB,YAAY,CAAU;IAE9B,YAAY,EACX,KAAK,EACL,WAAW,GAAG,CAAC,EACf,MAAM,EACN,YAAY,GAAG,IAAI,GAYnB;QACA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACvD,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,MAAmB,EAAE,QAAkB;QAChE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,UAAU,GAAkB,IAAI,CAAC;QACrC,mFAAmF;QACnF,IAAI,KAAyB,CAAC;QAC9B,wEAAwE;QACxE,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,KAAK,IAAI,OAAO,GAAG,CAAC,GAAI,OAAO,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC;gBACJ,MAAM,YAAY,GAAG,UAAU,IAAI,MAAM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Ae,EAAE,UAAU;qBAC3B,CAAC,CAAC;gBAEJ,oFAAoF;gBACpF,8CAA8C;gBAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACvB,UAAU,GAAG,GAAG,MAAM,6DAA6D,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC9F,CAAC;gBACD,IAAI,CAAC;oBACJ,WAAW,CACV,GAAG,EAAE;wBACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CACf,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EACzE,CAAC,CACD,CAAC;oBACH,CAAC,EACD,mBAAmB,EACnB,qDAAqD,CACrD,CAAC;gBACH,CAAC;gBAAC,OAAO,UAAU,EAAE,CAAC;oBACrB,oEAAoE;oBACpE,MAAM,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;gBACtD,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { Agent, AgentResponse, Callback } from '#src/agent/domain/agent';\nimport { RecoverableError, UnrecoverableError, withSpentTokens } from '#src/agent/domain/errors';\nimport {\n\tclassifyHostFailure,\n\tdescribeFailure,\n\ttreatErrors,\n} from '#src/agent/domain/providerFailure';\nimport { isAbortError } from '#src/shared/domain/isAbortError';\nimport type { ILogger } from '#src/shared/domain/logger';\nimport { addTokens, type Tokens } from '#src/shared/domain/tokens';\n\nexport class RetryingAgent implements Agent {\n\tprivate inner: Agent;\n\tprivate maxAttempts: number;\n\tprivate logger: ILogger;\n\tprivate noteFailures: boolean;\n\n\tconstructor({\n\t\tinner,\n\t\tmaxAttempts = 3,\n\t\tlogger,\n\t\tnoteFailures = true,\n\t}: {\n\t\tinner: Agent;\n\t\tmaxAttempts?: number;\n\t\tlogger: ILogger;\n\t\t/**\n\t\t * Appends the previous failure to the retried prompt, so a provider session that may\n\t\t * remember the failed turn is told what happened. Off for an agent that records nothing\n\t\t * from a failed call, such as `LLMAgent`: there the note would become a permanent user\n\t\t * message resent on every later turn.\n\t\t */\n\t\tnoteFailures?: boolean;\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\tthis.noteFailures = noteFailures;\n\t}\n\n\tasync run(prompt: string, signal: AbortSignal, callback: Callback): Promise<AgentResponse> {\n\t\tconst start = Date.now();\n\t\tlet lastPrompt: string | null = null;\n\t\t// Failed attempts were billed too, so they travel with whichever way the run ends.\n\t\tlet spent: Tokens | undefined;\n\t\t// An attempt was answered without usage, so `spent` is only a subtotal.\n\t\tlet unreported = false;\n\n\t\tfor (let attempt = 1; ; attempt++) {\n\t\t\ttry {\n\t\t\t\tconst promptToSend = lastPrompt ?? prompt;\n\t\t\t\tconst response = await this.inner.run(promptToSend, signal, callback);\n\t\t\t\treturn {\n\t\t\t\t\t...response,\n\t\t\t\t\t// Any call answered without usage makes the whole count unknown, not partial.\n\t\t\t\t\ttokens: unreported ? undefined : response.tokens && addTokens(spent, response.tokens),\n\t\t\t\t\t// Every attempt was waited for, not only the last one.\n\t\t\t\t\tduration: (Date.now() - start) / 1000,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\tif (isAbortError(e)) throw e;\n\t\t\t\tif (e instanceof UnrecoverableError) throw withSpentTokens(e, spent, unreported);\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\ttokens: spent,\n\t\t\t\t\t\tusageUnreported: unreported,\n\t\t\t\t\t});\n\n\t\t\t\tspent = addTokens(spent, e.tokens);\n\t\t\t\tunreported ||= e.usageUnreported;\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\ttokens: spent,\n\t\t\t\t\t\tusageUnreported: unreported,\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\tif (this.noteFailures) {\n\t\t\t\t\tlastPrompt = `${prompt}\\n\\nThe previous attempt failed for the following reason: ${e.cause}`;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\ttreatErrors(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t\t`Attempt ${String(attempt)}/${String(this.maxAttempts)} failed; retrying`,\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tclassifyHostFailure,\n\t\t\t\t\t\t'RetryingAgent logger failed while reporting a retry',\n\t\t\t\t\t);\n\t\t\t\t} catch (logFailure) {\n\t\t\t\t\t// The attempts already spent their tokens, whatever the logger did.\n\t\t\t\t\tthrow withSpentTokens(logFailure, spent, unreported);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikode13/harness",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Test/agent harness utility",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -17,6 +17,12 @@
17
17
  "exports": {
18
18
  ".": "./dist/index.js"
19
19
  },
20
+ "imports": {
21
+ "#src/*": {
22
+ "mikode-harness-source": "./src/*.ts",
23
+ "default": "./dist/*.js"
24
+ }
25
+ },
20
26
  "files": [
21
27
  "dist"
22
28
  ],
@@ -41,7 +47,6 @@
41
47
  "check": "pnpm run format:check && pnpm run lint && pnpm run typecheck"
42
48
  },
43
49
  "devDependencies": {
44
- "@anthropic-ai/sdk": "^0.115.0",
45
50
  "@mikode13/code-quality": "1.0.0",
46
51
  "@mikode13/code-style": "1.0.0",
47
52
  "@mikode13/cross-platform": "1.1.0",
@@ -56,6 +61,7 @@
56
61
  },
57
62
  "dependencies": {
58
63
  "@anthropic-ai/claude-agent-sdk": "^0.3.220",
64
+ "@anthropic-ai/sdk": "^0.115.0",
59
65
  "@openai/codex-sdk": "^0.154.0",
60
66
  "openai": "^7.23.0",
61
67
  "zod": "^4.4.3"