@agntk/agent-harness 0.1.3 → 0.1.5

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 (123) hide show
  1. package/dist/{agent-framework-K4GUIICH.js → agent-framework-CMFC3VJM.js} +8 -8
  2. package/dist/{auto-processor-OLE45UI3.js → auto-processor-SDAJF67T.js} +3 -3
  3. package/dist/{chunk-XTBKL5BI.js → chunk-2ENYRENZ.js} +2 -2
  4. package/dist/{chunk-UPLBF4RZ.js → chunk-2UVWCTAY.js} +2 -2
  5. package/dist/{chunk-4CWAGBNS.js → chunk-4TQQZILG.js} +73 -3
  6. package/dist/chunk-4TQQZILG.js.map +1 -0
  7. package/dist/{chunk-A7BJPQQ6.js → chunk-5O5OGOOQ.js} +2 -2
  8. package/dist/{chunk-UWQTZMNI.js → chunk-7GZ4D6V6.js} +2 -2
  9. package/dist/{chunk-FLZU44SV.js → chunk-AN6Y4MDD.js} +6 -6
  10. package/dist/{chunk-4FDUOGSZ.js → chunk-D7AWV24Z.js} +3 -3
  11. package/dist/{chunk-CHJ5GNZC.js → chunk-EC42HQQH.js} +2 -2
  12. package/dist/{chunk-274RV3YO.js → chunk-GX2RCSFJ.js} +3 -3
  13. package/dist/{chunk-GJNNR2RA.js → chunk-M6PDMK2O.js} +3 -3
  14. package/dist/{chunk-GUJTBGVS.js → chunk-MSO7DKBK.js} +99 -188
  15. package/dist/chunk-MSO7DKBK.js.map +1 -0
  16. package/dist/{chunk-CSL3ERUI.js → chunk-NBEAK63K.js} +3 -3
  17. package/dist/{chunk-DA7IKHC4.js → chunk-NOJW5KG2.js} +2 -2
  18. package/dist/{chunk-M7NXUK55.js → chunk-NVC2WY4K.js} +2 -2
  19. package/dist/{chunk-YIJY5DBV.js → chunk-P74KXHA4.js} +4 -4
  20. package/dist/{chunk-YUFNYN2H.js → chunk-PTQ37NRI.js} +4 -4
  21. package/dist/{chunk-KFX54TQM.js → chunk-RPBC2QOA.js} +73 -3
  22. package/dist/chunk-RPBC2QOA.js.map +1 -0
  23. package/dist/{chunk-RY3ZFII7.js → chunk-SEHAQTBO.js} +6 -6
  24. package/dist/{chunk-MPZ3BPUI.js → chunk-UMXPOYZR.js} +4 -4
  25. package/dist/{chunk-W4T7PGI2.js → chunk-UXCHAS3Z.js} +4 -4
  26. package/dist/chunk-XVFVTDE6.js +98 -0
  27. package/dist/chunk-XVFVTDE6.js.map +1 -0
  28. package/dist/cli/index.js +105 -104
  29. package/dist/cli/index.js.map +1 -1
  30. package/dist/{config-WVMRUOCA.js → config-2O6S2YJO.js} +3 -3
  31. package/dist/config-LLQZYN2Q.js +11 -0
  32. package/dist/{context-loader-3ORBPMHJ.js → context-loader-XCZ5EXNG.js} +4 -4
  33. package/dist/{conversation-QDEIDQPH.js → conversation-OPLE23IM.js} +6 -6
  34. package/dist/{delegate-VJCJLYEK.js → delegate-ZJCIADNN.js} +7 -7
  35. package/dist/{export-6GCYHEHQ.js → export-2HEAAOUF.js} +3 -3
  36. package/dist/{graph-YUIPOSOO.js → graph-5MKRTC3J.js} +4 -4
  37. package/dist/harness-ABKZWP47.js +11 -0
  38. package/dist/{harness-WE4SLCML.js → harness-XSBQBY7T.js} +8 -8
  39. package/dist/index.d.ts +22 -0
  40. package/dist/index.js +226 -6
  41. package/dist/index.js.map +1 -1
  42. package/dist/{indexer-LONANRRM.js → indexer-YKSGUVYT.js} +4 -4
  43. package/dist/{instinct-learner-SRM72DHF.js → instinct-learner-CWVMLUWX.js} +5 -5
  44. package/dist/{intake-4M3HNU43.js → intake-M5NRR6QR.js} +5 -5
  45. package/dist/{intelligence-HJOCA4SJ.js → intelligence-UW4TCOC7.js} +10 -10
  46. package/dist/{journal-WANJL3MI.js → journal-KN265YLU.js} +5 -5
  47. package/dist/{loader-C3TKIKZR.js → loader-BOCVXVCH.js} +3 -3
  48. package/dist/{mcp-installer-6O2XXD3V.js → mcp-installer-KV3XZRRF.js} +3 -3
  49. package/dist/{primitive-registry-I6VTIR4W.js → primitive-registry-HOJMUFBT.js} +3 -3
  50. package/dist/{rule-engine-YGQ3RYZM.js → rule-engine-I4AFQSSR.js} +3 -3
  51. package/dist/{scaffold-A3VRRCBV.js → scaffold-ZY4XWINP.js} +4 -4
  52. package/dist/{scheduler-XHHIVHRI.js → scheduler-TYOQKO4C.js} +11 -11
  53. package/dist/{search-V3W5JMJG.js → search-4IYM525O.js} +3 -3
  54. package/dist/{semantic-search-2DTOO5UX.js → semantic-search-G624D6CI.js} +3 -3
  55. package/dist/{serve-DTQ3HENY.js → serve-QFUZWOU3.js} +9 -9
  56. package/dist/{telemetry-UC6PBXC7.js → telemetry-MVDNGJEC.js} +4 -4
  57. package/dist/{tool-executor-MJ7IG7PQ.js → tool-executor-KEYQLO4M.js} +5 -5
  58. package/dist/{tools-DZ4KETET.js → tools-EB3BHRRF.js} +4 -4
  59. package/dist/{types-EW7AIB3R.js → types-NYKB2DN3.js} +2 -2
  60. package/dist/{types-WGDLSPO6.js → types-VRSXU4AM.js} +2 -2
  61. package/dist/{universal-installer-EVBDGOWM.js → universal-installer-7MFCJUW7.js} +228 -6
  62. package/dist/universal-installer-7MFCJUW7.js.map +1 -0
  63. package/dist/{validator-7WXMDIHH.js → validator-LZXBFEPV.js} +8 -8
  64. package/dist/{verification-gate-FYXUX6LH.js → verification-gate-ALSJVKSW.js} +3 -3
  65. package/dist/{watcher-ISJC7YKL.js → watcher-CSHVDOCM.js} +5 -5
  66. package/dist/{web-server-DD7ZOP46.js → web-server-7NGOTK7J.js} +8 -8
  67. package/dist/web-server-7NGOTK7J.js.map +1 -0
  68. package/package.json +1 -1
  69. package/dist/chunk-4CWAGBNS.js.map +0 -1
  70. package/dist/chunk-GUJTBGVS.js.map +0 -1
  71. package/dist/chunk-KFX54TQM.js.map +0 -1
  72. package/dist/harness-LCHA3DWP.js +0 -10
  73. package/dist/universal-installer-EVBDGOWM.js.map +0 -1
  74. /package/dist/{agent-framework-K4GUIICH.js.map → agent-framework-CMFC3VJM.js.map} +0 -0
  75. /package/dist/{auto-processor-OLE45UI3.js.map → auto-processor-SDAJF67T.js.map} +0 -0
  76. /package/dist/{chunk-XTBKL5BI.js.map → chunk-2ENYRENZ.js.map} +0 -0
  77. /package/dist/{chunk-UPLBF4RZ.js.map → chunk-2UVWCTAY.js.map} +0 -0
  78. /package/dist/{chunk-A7BJPQQ6.js.map → chunk-5O5OGOOQ.js.map} +0 -0
  79. /package/dist/{chunk-UWQTZMNI.js.map → chunk-7GZ4D6V6.js.map} +0 -0
  80. /package/dist/{chunk-FLZU44SV.js.map → chunk-AN6Y4MDD.js.map} +0 -0
  81. /package/dist/{chunk-4FDUOGSZ.js.map → chunk-D7AWV24Z.js.map} +0 -0
  82. /package/dist/{chunk-CHJ5GNZC.js.map → chunk-EC42HQQH.js.map} +0 -0
  83. /package/dist/{chunk-274RV3YO.js.map → chunk-GX2RCSFJ.js.map} +0 -0
  84. /package/dist/{chunk-GJNNR2RA.js.map → chunk-M6PDMK2O.js.map} +0 -0
  85. /package/dist/{chunk-CSL3ERUI.js.map → chunk-NBEAK63K.js.map} +0 -0
  86. /package/dist/{chunk-DA7IKHC4.js.map → chunk-NOJW5KG2.js.map} +0 -0
  87. /package/dist/{chunk-M7NXUK55.js.map → chunk-NVC2WY4K.js.map} +0 -0
  88. /package/dist/{chunk-YIJY5DBV.js.map → chunk-P74KXHA4.js.map} +0 -0
  89. /package/dist/{chunk-YUFNYN2H.js.map → chunk-PTQ37NRI.js.map} +0 -0
  90. /package/dist/{chunk-RY3ZFII7.js.map → chunk-SEHAQTBO.js.map} +0 -0
  91. /package/dist/{chunk-MPZ3BPUI.js.map → chunk-UMXPOYZR.js.map} +0 -0
  92. /package/dist/{chunk-W4T7PGI2.js.map → chunk-UXCHAS3Z.js.map} +0 -0
  93. /package/dist/{config-WVMRUOCA.js.map → config-2O6S2YJO.js.map} +0 -0
  94. /package/dist/{context-loader-3ORBPMHJ.js.map → config-LLQZYN2Q.js.map} +0 -0
  95. /package/dist/{conversation-QDEIDQPH.js.map → context-loader-XCZ5EXNG.js.map} +0 -0
  96. /package/dist/{delegate-VJCJLYEK.js.map → conversation-OPLE23IM.js.map} +0 -0
  97. /package/dist/{graph-YUIPOSOO.js.map → delegate-ZJCIADNN.js.map} +0 -0
  98. /package/dist/{export-6GCYHEHQ.js.map → export-2HEAAOUF.js.map} +0 -0
  99. /package/dist/{harness-LCHA3DWP.js.map → graph-5MKRTC3J.js.map} +0 -0
  100. /package/dist/{harness-WE4SLCML.js.map → harness-ABKZWP47.js.map} +0 -0
  101. /package/dist/{indexer-LONANRRM.js.map → harness-XSBQBY7T.js.map} +0 -0
  102. /package/dist/{instinct-learner-SRM72DHF.js.map → indexer-YKSGUVYT.js.map} +0 -0
  103. /package/dist/{intake-4M3HNU43.js.map → instinct-learner-CWVMLUWX.js.map} +0 -0
  104. /package/dist/{journal-WANJL3MI.js.map → intake-M5NRR6QR.js.map} +0 -0
  105. /package/dist/{intelligence-HJOCA4SJ.js.map → intelligence-UW4TCOC7.js.map} +0 -0
  106. /package/dist/{loader-C3TKIKZR.js.map → journal-KN265YLU.js.map} +0 -0
  107. /package/dist/{telemetry-UC6PBXC7.js.map → loader-BOCVXVCH.js.map} +0 -0
  108. /package/dist/{mcp-installer-6O2XXD3V.js.map → mcp-installer-KV3XZRRF.js.map} +0 -0
  109. /package/dist/{primitive-registry-I6VTIR4W.js.map → primitive-registry-HOJMUFBT.js.map} +0 -0
  110. /package/dist/{rule-engine-YGQ3RYZM.js.map → rule-engine-I4AFQSSR.js.map} +0 -0
  111. /package/dist/{scaffold-A3VRRCBV.js.map → scaffold-ZY4XWINP.js.map} +0 -0
  112. /package/dist/{scheduler-XHHIVHRI.js.map → scheduler-TYOQKO4C.js.map} +0 -0
  113. /package/dist/{search-V3W5JMJG.js.map → search-4IYM525O.js.map} +0 -0
  114. /package/dist/{semantic-search-2DTOO5UX.js.map → semantic-search-G624D6CI.js.map} +0 -0
  115. /package/dist/{serve-DTQ3HENY.js.map → serve-QFUZWOU3.js.map} +0 -0
  116. /package/dist/{tool-executor-MJ7IG7PQ.js.map → telemetry-MVDNGJEC.js.map} +0 -0
  117. /package/dist/{tools-DZ4KETET.js.map → tool-executor-KEYQLO4M.js.map} +0 -0
  118. /package/dist/{types-EW7AIB3R.js.map → tools-EB3BHRRF.js.map} +0 -0
  119. /package/dist/{types-WGDLSPO6.js.map → types-NYKB2DN3.js.map} +0 -0
  120. /package/dist/{validator-7WXMDIHH.js.map → types-VRSXU4AM.js.map} +0 -0
  121. /package/dist/{web-server-DD7ZOP46.js.map → validator-LZXBFEPV.js.map} +0 -0
  122. /package/dist/{verification-gate-FYXUX6LH.js.map → verification-gate-ALSJVKSW.js.map} +0 -0
  123. /package/dist/{watcher-ISJC7YKL.js.map → watcher-CSHVDOCM.js.map} +0 -0
@@ -1,9 +1,10 @@
1
1
  import {
2
- CONFIG_DEFAULTS,
2
+ loadConfig
3
+ } from "./chunk-XVFVTDE6.js";
4
+ import {
3
5
  CORE_PRIMITIVE_DIRS,
4
- FrontmatterSchema,
5
- HarnessConfigSchema
6
- } from "./chunk-KFX54TQM.js";
6
+ FrontmatterSchema
7
+ } from "./chunk-RPBC2QOA.js";
7
8
  import {
8
9
  generate,
9
10
  getModel,
@@ -11,97 +12,9 @@ import {
11
12
  } from "./chunk-FD55B3IO.js";
12
13
 
13
14
  // src/core/harness.ts
14
- import { existsSync as existsSync11 } from "fs";
15
+ import { existsSync as existsSync10 } from "fs";
15
16
  import { resolve } from "path";
16
17
 
17
- // src/core/config.ts
18
- import { readFileSync, existsSync } from "fs";
19
- import { join } from "path";
20
- import YAML from "yaml";
21
- var CONFIG_FILENAMES = ["config.yaml", "config.yml", "harness.yaml", "harness.yml"];
22
- function loadConfig(dir, overrides) {
23
- let raw = {};
24
- for (const filename of CONFIG_FILENAMES) {
25
- const configPath = join(dir, filename);
26
- if (existsSync(configPath)) {
27
- const content = readFileSync(configPath, "utf-8");
28
- raw = YAML.parse(content) || {};
29
- break;
30
- }
31
- }
32
- let merged = deepMerge(
33
- CONFIG_DEFAULTS,
34
- raw
35
- );
36
- if (overrides) {
37
- merged = deepMerge(
38
- merged,
39
- overrides
40
- );
41
- }
42
- const result = HarnessConfigSchema.safeParse(merged);
43
- if (!result.success) {
44
- const issues = result.error.issues.map((i) => ` ${i.path.join(".")}: ${i.message}`).join("\n");
45
- throw new Error(`Invalid config:
46
- ${issues}`);
47
- }
48
- return result.data;
49
- }
50
- function writeDefaultConfig(_dir, agentName = "my-agent") {
51
- return `# Agent Harness Configuration
52
- agent:
53
- name: ${agentName}
54
- version: "0.1.0"
55
-
56
- model:
57
- provider: openrouter
58
- id: anthropic/claude-sonnet-4
59
- max_tokens: 200000
60
- max_retries: 2
61
- # timeout_ms: 60000
62
-
63
- runtime:
64
- scratchpad_budget: 10000
65
- timezone: America/New_York
66
- # heartbeat: "0 6-23 * * *" # reserved, not yet implemented
67
- # daily_summary: "0 22 * * *" # reserved, not yet implemented
68
-
69
- memory:
70
- session_retention_days: 7
71
- journal_retention_days: 365
72
-
73
- channels:
74
- primary: cli
75
-
76
- extensions:
77
- directories: []
78
-
79
- # rate_limits:
80
- # per_minute: 10
81
- # per_hour: 100
82
- # per_day: 500
83
-
84
- # budget:
85
- # daily_limit_usd: 5.00
86
- # monthly_limit_usd: 100.00
87
- # enforce: true
88
- `;
89
- }
90
- function deepMerge(target, source) {
91
- const result = { ...target };
92
- for (const key of Object.keys(source)) {
93
- if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key]) && target[key] && typeof target[key] === "object" && !Array.isArray(target[key])) {
94
- result[key] = deepMerge(
95
- target[key],
96
- source[key]
97
- );
98
- } else {
99
- result[key] = source[key];
100
- }
101
- }
102
- return result;
103
- }
104
-
105
18
  // src/core/logger.ts
106
19
  var LEVEL_ORDER = {
107
20
  debug: 0,
@@ -159,17 +72,17 @@ function getGlobalLogLevel() {
159
72
  var log = createLogger("harness");
160
73
 
161
74
  // src/runtime/context-loader.ts
162
- import { readFileSync as readFileSync3, existsSync as existsSync3 } from "fs";
163
- import { join as join3 } from "path";
75
+ import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
76
+ import { join as join2 } from "path";
164
77
 
165
78
  // src/primitives/loader.ts
166
- import { readFileSync as readFileSync2, readdirSync, existsSync as existsSync2 } from "fs";
167
- import { join as join2, extname } from "path";
79
+ import { readFileSync, readdirSync, existsSync } from "fs";
80
+ import { join, extname } from "path";
168
81
  import matter from "gray-matter";
169
82
  var L0_REGEX = /<!--\s*L0:\s*([\s\S]*?)\s*-->/;
170
83
  var L1_REGEX = /<!--\s*L1:\s*([\s\S]*?)\s*-->/;
171
84
  function parseHarnessDocument(filePath) {
172
- const raw = readFileSync2(filePath, "utf-8");
85
+ const raw = readFileSync(filePath, "utf-8");
173
86
  const { data, content } = matter(raw);
174
87
  const normalized = { ...data };
175
88
  for (const key of ["created", "updated"]) {
@@ -202,7 +115,7 @@ function loadDirectory(dirPath) {
202
115
  return loadDirectoryWithErrors(dirPath).docs;
203
116
  }
204
117
  function loadDirectoryWithErrors(dirPath) {
205
- if (!existsSync2(dirPath)) return { docs: [], errors: [] };
118
+ if (!existsSync(dirPath)) return { docs: [], errors: [] };
206
119
  const files = readdirSync(dirPath);
207
120
  const docs = [];
208
121
  const errors = [];
@@ -210,7 +123,7 @@ function loadDirectoryWithErrors(dirPath) {
210
123
  if (extname(file) !== ".md") continue;
211
124
  if (file.startsWith("_")) continue;
212
125
  if (file.startsWith(".")) continue;
213
- const filePath = join2(dirPath, file);
126
+ const filePath = join(dirPath, file);
214
127
  try {
215
128
  const doc = parseHarnessDocument(filePath);
216
129
  if (doc.frontmatter.status !== "archived" && doc.frontmatter.status !== "deprecated") {
@@ -240,7 +153,7 @@ function loadAllPrimitivesWithErrors(harnessDir, extraDirs) {
240
153
  }
241
154
  }
242
155
  for (const dir of directories) {
243
- const { docs, errors } = loadDirectoryWithErrors(join2(harnessDir, dir));
156
+ const { docs, errors } = loadDirectoryWithErrors(join(harnessDir, dir));
244
157
  primitives.set(dir, docs);
245
158
  allErrors.push(...errors);
246
159
  }
@@ -271,27 +184,27 @@ function buildSystemPrompt(harnessDir, config) {
271
184
  };
272
185
  const warnings = [];
273
186
  const sections = [];
274
- const corePath = join3(harnessDir, "CORE.md");
275
- if (existsSync3(corePath)) {
276
- const core = readFileSync3(corePath, "utf-8");
187
+ const corePath = join2(harnessDir, "CORE.md");
188
+ if (existsSync2(corePath)) {
189
+ const core = readFileSync2(corePath, "utf-8");
277
190
  sections.push(`# CORE IDENTITY
278
191
 
279
192
  ${core}`);
280
193
  budget.used_tokens += estimateTokens(core);
281
194
  budget.loaded_files.push("CORE.md");
282
195
  }
283
- const statePath = join3(harnessDir, "state.md");
284
- if (existsSync3(statePath)) {
285
- const state = readFileSync3(statePath, "utf-8");
196
+ const statePath = join2(harnessDir, "state.md");
197
+ if (existsSync2(statePath)) {
198
+ const state = readFileSync2(statePath, "utf-8");
286
199
  sections.push(`# CURRENT STATE
287
200
 
288
201
  ${state}`);
289
202
  budget.used_tokens += estimateTokens(state);
290
203
  budget.loaded_files.push("state.md");
291
204
  }
292
- const systemPath = join3(harnessDir, "SYSTEM.md");
293
- if (existsSync3(systemPath)) {
294
- const system = readFileSync3(systemPath, "utf-8");
205
+ const systemPath = join2(harnessDir, "SYSTEM.md");
206
+ if (existsSync2(systemPath)) {
207
+ const system = readFileSync2(systemPath, "utf-8");
295
208
  sections.push(`# SYSTEM
296
209
 
297
210
  ${system}`);
@@ -364,9 +277,9 @@ ${content}`);
364
277
  ${categoryDocs.join("\n\n")}`);
365
278
  }
366
279
  }
367
- const scratchPath = join3(harnessDir, "memory", "scratch.md");
368
- if (existsSync3(scratchPath)) {
369
- const scratch = readFileSync3(scratchPath, "utf-8");
280
+ const scratchPath = join2(harnessDir, "memory", "scratch.md");
281
+ if (existsSync2(scratchPath)) {
282
+ const scratch = readFileSync2(scratchPath, "utf-8");
370
283
  if (scratch.trim()) {
371
284
  sections.push(`# SCRATCH (Current Working Memory)
372
285
 
@@ -398,27 +311,27 @@ ${scratch}`);
398
311
  }
399
312
 
400
313
  // src/runtime/state.ts
401
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync2, existsSync as existsSync5 } from "fs";
402
- import { join as join5 } from "path";
314
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync4 } from "fs";
315
+ import { join as join4 } from "path";
403
316
 
404
317
  // src/runtime/file-lock.ts
405
- import { writeFileSync, unlinkSync, readFileSync as readFileSync4, existsSync as existsSync4, mkdirSync } from "fs";
406
- import { join as join4, basename } from "path";
318
+ import { writeFileSync, unlinkSync, readFileSync as readFileSync3, existsSync as existsSync3, mkdirSync } from "fs";
319
+ import { join as join3, basename } from "path";
407
320
  var DEFAULT_STALE_MS = 3e4;
408
321
  var DEFAULT_RETRY_MS = 50;
409
322
  var DEFAULT_WAIT_MS = 5e3;
410
323
  function getLockDir(harnessDir) {
411
- return join4(harnessDir, "memory");
324
+ return join3(harnessDir, "memory");
412
325
  }
413
326
  function getLockPath(harnessDir, filePath) {
414
327
  const lockDir = getLockDir(harnessDir);
415
328
  const lockName = basename(filePath).replace(/\.[^.]+$/, "") + ".lock";
416
- return join4(lockDir, lockName);
329
+ return join3(lockDir, lockName);
417
330
  }
418
331
  function readLockInfo(lockPath) {
419
- if (!existsSync4(lockPath)) return null;
332
+ if (!existsSync3(lockPath)) return null;
420
333
  try {
421
- const content = readFileSync4(lockPath, "utf-8");
334
+ const content = readFileSync3(lockPath, "utf-8");
422
335
  const parsed = JSON.parse(content);
423
336
  if (typeof parsed === "object" && parsed !== null && "pid" in parsed && "acquired" in parsed) {
424
337
  return parsed;
@@ -442,7 +355,7 @@ function tryLock(harnessDir, filePath, options) {
442
355
  const staleMs = options?.staleMs ?? DEFAULT_STALE_MS;
443
356
  const lockPath = getLockPath(harnessDir, filePath);
444
357
  const lockDir = getLockDir(harnessDir);
445
- if (!existsSync4(lockDir)) {
358
+ if (!existsSync3(lockDir)) {
446
359
  mkdirSync(lockDir, { recursive: true });
447
360
  }
448
361
  const existing = readLockInfo(lockPath);
@@ -470,7 +383,7 @@ function tryLock(harnessDir, filePath, options) {
470
383
  }
471
384
  function releaseLock(harnessDir, filePath) {
472
385
  const lockPath = getLockPath(harnessDir, filePath);
473
- if (!existsSync4(lockPath)) return;
386
+ if (!existsSync3(lockPath)) return;
474
387
  const info = readLockInfo(lockPath);
475
388
  if (info && info.pid === process.pid) {
476
389
  try {
@@ -520,7 +433,7 @@ function isLocked(harnessDir, filePath, options) {
520
433
  }
521
434
  function breakLock(harnessDir, filePath) {
522
435
  const lockPath = getLockPath(harnessDir, filePath);
523
- if (!existsSync4(lockPath)) return false;
436
+ if (!existsSync3(lockPath)) return false;
524
437
  try {
525
438
  unlinkSync(lockPath);
526
439
  return true;
@@ -538,15 +451,15 @@ var DEFAULT_STATE = {
538
451
  unfinished_business: []
539
452
  };
540
453
  function loadState(harnessDir) {
541
- const statePath = join5(harnessDir, "state.md");
542
- if (!existsSync5(statePath)) {
454
+ const statePath = join4(harnessDir, "state.md");
455
+ if (!existsSync4(statePath)) {
543
456
  return { ...DEFAULT_STATE };
544
457
  }
545
- const content = readFileSync5(statePath, "utf-8");
458
+ const content = readFileSync4(statePath, "utf-8");
546
459
  return parseStateMd(content);
547
460
  }
548
461
  function saveState(harnessDir, state) {
549
- const statePath = join5(harnessDir, "state.md");
462
+ const statePath = join4(harnessDir, "state.md");
550
463
  const content = renderStateMd(state);
551
464
  withFileLockSync(harnessDir, statePath, () => {
552
465
  writeFileSync2(statePath, content, "utf-8");
@@ -596,8 +509,8 @@ function renderStateMd(state) {
596
509
  }
597
510
 
598
511
  // src/runtime/sessions.ts
599
- import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync6, readdirSync as readdirSync2, unlinkSync as unlinkSync2, copyFileSync } from "fs";
600
- import { join as join6 } from "path";
512
+ import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync5, readdirSync as readdirSync2, unlinkSync as unlinkSync2, copyFileSync } from "fs";
513
+ import { join as join5 } from "path";
601
514
  import { randomUUID } from "crypto";
602
515
  function createSessionId() {
603
516
  const now = /* @__PURE__ */ new Date();
@@ -621,11 +534,11 @@ function formatToolCalls(toolCalls) {
621
534
  return lines.join("\n");
622
535
  }
623
536
  function writeSession(harnessDir, session) {
624
- const sessionsDir = join6(harnessDir, "memory", "sessions");
625
- if (!existsSync6(sessionsDir)) {
537
+ const sessionsDir = join5(harnessDir, "memory", "sessions");
538
+ if (!existsSync5(sessionsDir)) {
626
539
  mkdirSync2(sessionsDir, { recursive: true });
627
540
  }
628
- const filePath = join6(sessionsDir, `${session.id}.md`);
541
+ const filePath = join5(sessionsDir, `${session.id}.md`);
629
542
  const tags = session.delegated_to ? `[session, delegation, ${session.delegated_to}]` : "[session]";
630
543
  const modelLine = session.model_id ? `
631
544
  **Model:** ${session.model_id}` : "";
@@ -671,8 +584,8 @@ function archiveOldFiles(harnessDir, sessionRetentionDays, journalRetentionDays)
671
584
  journalFiles: []
672
585
  };
673
586
  const now = Date.now();
674
- const sessionsDir = join6(harnessDir, "memory", "sessions");
675
- if (existsSync6(sessionsDir)) {
587
+ const sessionsDir = join5(harnessDir, "memory", "sessions");
588
+ if (existsSync5(sessionsDir)) {
676
589
  const cutoff = now - sessionRetentionDays * 24 * 60 * 60 * 1e3;
677
590
  const files = readdirSync2(sessionsDir).filter(
678
591
  (f) => f.endsWith(".md") && !f.startsWith(".") && !f.startsWith("_")
@@ -681,17 +594,17 @@ function archiveOldFiles(harnessDir, sessionRetentionDays, journalRetentionDays)
681
594
  const dateStr = extractDateFromFilename(file);
682
595
  if (dateStr && new Date(dateStr).getTime() < cutoff) {
683
596
  const yearMonth = dateStr.slice(0, 7);
684
- const archiveDir = join6(sessionsDir, "archive", yearMonth);
597
+ const archiveDir = join5(sessionsDir, "archive", yearMonth);
685
598
  mkdirSync2(archiveDir, { recursive: true });
686
- copyFileSync(join6(sessionsDir, file), join6(archiveDir, file));
687
- unlinkSync2(join6(sessionsDir, file));
599
+ copyFileSync(join5(sessionsDir, file), join5(archiveDir, file));
600
+ unlinkSync2(join5(sessionsDir, file));
688
601
  result.sessionsArchived++;
689
602
  result.sessionFiles.push(file);
690
603
  }
691
604
  }
692
605
  }
693
- const journalDir = join6(harnessDir, "memory", "journal");
694
- if (existsSync6(journalDir)) {
606
+ const journalDir = join5(harnessDir, "memory", "journal");
607
+ if (existsSync5(journalDir)) {
695
608
  const cutoff = now - journalRetentionDays * 24 * 60 * 60 * 1e3;
696
609
  const files = readdirSync2(journalDir).filter(
697
610
  (f) => f.endsWith(".md") && !f.startsWith(".") && !f.startsWith("_")
@@ -700,10 +613,10 @@ function archiveOldFiles(harnessDir, sessionRetentionDays, journalRetentionDays)
700
613
  const dateStr = extractDateFromFilename(file);
701
614
  if (dateStr && new Date(dateStr).getTime() < cutoff) {
702
615
  const yearMonth = dateStr.slice(0, 7);
703
- const archiveDir = join6(journalDir, "archive", yearMonth);
616
+ const archiveDir = join5(journalDir, "archive", yearMonth);
704
617
  mkdirSync2(archiveDir, { recursive: true });
705
- copyFileSync(join6(journalDir, file), join6(archiveDir, file));
706
- unlinkSync2(join6(journalDir, file));
618
+ copyFileSync(join5(journalDir, file), join5(archiveDir, file));
619
+ unlinkSync2(join5(journalDir, file));
707
620
  result.journalsArchived++;
708
621
  result.journalFiles.push(file);
709
622
  }
@@ -719,27 +632,27 @@ function cleanupOldFiles(harnessDir, sessionRetentionDays, journalRetentionDays)
719
632
  journalFiles: []
720
633
  };
721
634
  const now = Date.now();
722
- const sessionsDir = join6(harnessDir, "memory", "sessions");
723
- if (existsSync6(sessionsDir)) {
635
+ const sessionsDir = join5(harnessDir, "memory", "sessions");
636
+ if (existsSync5(sessionsDir)) {
724
637
  const cutoff = now - sessionRetentionDays * 24 * 60 * 60 * 1e3;
725
638
  const files = readdirSync2(sessionsDir).filter((f) => f.endsWith(".md") && !f.startsWith("."));
726
639
  for (const file of files) {
727
640
  const dateStr = extractDateFromFilename(file);
728
641
  if (dateStr && new Date(dateStr).getTime() < cutoff) {
729
- unlinkSync2(join6(sessionsDir, file));
642
+ unlinkSync2(join5(sessionsDir, file));
730
643
  result.sessionsRemoved++;
731
644
  result.sessionFiles.push(file);
732
645
  }
733
646
  }
734
647
  }
735
- const journalDir = join6(harnessDir, "memory", "journal");
736
- if (existsSync6(journalDir)) {
648
+ const journalDir = join5(harnessDir, "memory", "journal");
649
+ if (existsSync5(journalDir)) {
737
650
  const cutoff = now - journalRetentionDays * 24 * 60 * 60 * 1e3;
738
651
  const files = readdirSync2(journalDir).filter((f) => f.endsWith(".md") && !f.startsWith("."));
739
652
  for (const file of files) {
740
653
  const dateStr = extractDateFromFilename(file);
741
654
  if (dateStr && new Date(dateStr).getTime() < cutoff) {
742
- unlinkSync2(join6(journalDir, file));
655
+ unlinkSync2(join5(journalDir, file));
743
656
  result.journalsRemoved++;
744
657
  result.journalFiles.push(file);
745
658
  }
@@ -754,20 +667,20 @@ function extractDateFromFilename(filename) {
754
667
  return isNaN(date.getTime()) ? null : match[1];
755
668
  }
756
669
  function listSessions(harnessDir) {
757
- const sessionsDir = join6(harnessDir, "memory", "sessions");
758
- if (!existsSync6(sessionsDir)) return [];
670
+ const sessionsDir = join5(harnessDir, "memory", "sessions");
671
+ if (!existsSync5(sessionsDir)) return [];
759
672
  return readdirSync2(sessionsDir).filter((f) => f.endsWith(".md") && !f.startsWith(".")).sort().reverse().map((f) => ({
760
673
  id: f.replace(".md", ""),
761
674
  date: extractDateFromFilename(f) || "unknown",
762
- path: join6(sessionsDir, f)
675
+ path: join5(sessionsDir, f)
763
676
  }));
764
677
  }
765
678
  function listExpiredFiles(harnessDir, sessionRetentionDays, journalRetentionDays) {
766
679
  const now = Date.now();
767
680
  const sessionFiles = [];
768
681
  const journalFiles = [];
769
- const sessionsDir = join6(harnessDir, "memory", "sessions");
770
- if (existsSync6(sessionsDir)) {
682
+ const sessionsDir = join5(harnessDir, "memory", "sessions");
683
+ if (existsSync5(sessionsDir)) {
771
684
  const cutoff = now - sessionRetentionDays * 24 * 60 * 60 * 1e3;
772
685
  const files = readdirSync2(sessionsDir).filter((f) => f.endsWith(".md") && !f.startsWith("."));
773
686
  for (const file of files) {
@@ -777,8 +690,8 @@ function listExpiredFiles(harnessDir, sessionRetentionDays, journalRetentionDays
777
690
  }
778
691
  }
779
692
  }
780
- const journalDir = join6(harnessDir, "memory", "journal");
781
- if (existsSync6(journalDir)) {
693
+ const journalDir = join5(harnessDir, "memory", "journal");
694
+ if (existsSync5(journalDir)) {
782
695
  const cutoff = now - journalRetentionDays * 24 * 60 * 60 * 1e3;
783
696
  const files = readdirSync2(journalDir).filter((f) => f.endsWith(".md") && !f.startsWith("."));
784
697
  for (const file of files) {
@@ -792,8 +705,8 @@ function listExpiredFiles(harnessDir, sessionRetentionDays, journalRetentionDays
792
705
  }
793
706
 
794
707
  // src/runtime/cost-tracker.ts
795
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync7, mkdirSync as mkdirSync3 } from "fs";
796
- import { join as join7 } from "path";
708
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync3 } from "fs";
709
+ import { join as join6 } from "path";
797
710
  var COST_FILE = "costs.json";
798
711
  var MAX_ENTRIES = 5e3;
799
712
  var DEFAULT_PRICING = [
@@ -814,15 +727,15 @@ var DEFAULT_PRICING = [
814
727
  { model_pattern: "local/", input_per_million: 0, output_per_million: 0 }
815
728
  ];
816
729
  function getStorePath(harnessDir) {
817
- return join7(harnessDir, "memory", COST_FILE);
730
+ return join6(harnessDir, "memory", COST_FILE);
818
731
  }
819
732
  function loadCosts(harnessDir) {
820
733
  const storePath = getStorePath(harnessDir);
821
- if (!existsSync7(storePath)) {
734
+ if (!existsSync6(storePath)) {
822
735
  return { entries: [], updated: (/* @__PURE__ */ new Date()).toISOString() };
823
736
  }
824
737
  try {
825
- const content = readFileSync6(storePath, "utf-8");
738
+ const content = readFileSync5(storePath, "utf-8");
826
739
  const parsed = JSON.parse(content);
827
740
  if (typeof parsed === "object" && parsed !== null && "entries" in parsed && Array.isArray(parsed.entries)) {
828
741
  return parsed;
@@ -833,8 +746,8 @@ function loadCosts(harnessDir) {
833
746
  }
834
747
  }
835
748
  function saveCosts(harnessDir, store) {
836
- const memoryDir = join7(harnessDir, "memory");
837
- if (!existsSync7(memoryDir)) {
749
+ const memoryDir = join6(harnessDir, "memory");
750
+ if (!existsSync6(memoryDir)) {
838
751
  mkdirSync3(memoryDir, { recursive: true });
839
752
  }
840
753
  if (store.entries.length > MAX_ENTRIES) {
@@ -975,11 +888,11 @@ function clearCosts(harnessDir, modelId) {
975
888
  }
976
889
 
977
890
  // src/runtime/health.ts
978
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
979
- import { join as join8 } from "path";
891
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, existsSync as existsSync7, mkdirSync as mkdirSync4 } from "fs";
892
+ import { join as join7 } from "path";
980
893
  var HEALTH_FILE = "health.json";
981
894
  function getHealthPath(harnessDir) {
982
- return join8(harnessDir, "memory", HEALTH_FILE);
895
+ return join7(harnessDir, "memory", HEALTH_FILE);
983
896
  }
984
897
  function defaultMetrics() {
985
898
  return {
@@ -996,11 +909,11 @@ function defaultMetrics() {
996
909
  }
997
910
  function loadHealth(harnessDir) {
998
911
  const healthPath = getHealthPath(harnessDir);
999
- if (!existsSync8(healthPath)) {
912
+ if (!existsSync7(healthPath)) {
1000
913
  return defaultMetrics();
1001
914
  }
1002
915
  try {
1003
- const content = readFileSync7(healthPath, "utf-8");
916
+ const content = readFileSync6(healthPath, "utf-8");
1004
917
  const parsed = JSON.parse(content);
1005
918
  if (typeof parsed === "object" && parsed !== null && "totalRuns" in parsed) {
1006
919
  return parsed;
@@ -1011,8 +924,8 @@ function loadHealth(harnessDir) {
1011
924
  }
1012
925
  }
1013
926
  function saveHealth(harnessDir, metrics) {
1014
- const memoryDir = join8(harnessDir, "memory");
1015
- if (!existsSync8(memoryDir)) {
927
+ const memoryDir = join7(harnessDir, "memory");
928
+ if (!existsSync7(memoryDir)) {
1016
929
  mkdirSync4(memoryDir, { recursive: true });
1017
930
  }
1018
931
  metrics.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -1044,14 +957,14 @@ function getHealthStatus(harnessDir) {
1044
957
  const metrics = loadHealth(harnessDir);
1045
958
  const checks = [];
1046
959
  const requiredFiles = ["CORE.md", "config.yaml", "state.md"];
1047
- const missingFiles = requiredFiles.filter((f) => !existsSync8(join8(harnessDir, f)));
960
+ const missingFiles = requiredFiles.filter((f) => !existsSync7(join7(harnessDir, f)));
1048
961
  if (missingFiles.length === 0) {
1049
962
  checks.push({ name: "core-files", status: "pass", message: "All core files present" });
1050
963
  } else {
1051
964
  checks.push({ name: "core-files", status: "fail", message: `Missing: ${missingFiles.join(", ")}` });
1052
965
  }
1053
- const memoryDir = join8(harnessDir, "memory");
1054
- if (existsSync8(memoryDir)) {
966
+ const memoryDir = join7(harnessDir, "memory");
967
+ if (existsSync7(memoryDir)) {
1055
968
  checks.push({ name: "memory-dir", status: "pass", message: "Memory directory exists" });
1056
969
  } else {
1057
970
  checks.push({ name: "memory-dir", status: "fail", message: "Memory directory missing" });
@@ -1126,20 +1039,20 @@ function resetHealth(harnessDir) {
1126
1039
  }
1127
1040
 
1128
1041
  // src/runtime/rate-limiter.ts
1129
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, existsSync as existsSync9, mkdirSync as mkdirSync5 } from "fs";
1130
- import { join as join9 } from "path";
1042
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync6, existsSync as existsSync8, mkdirSync as mkdirSync5 } from "fs";
1043
+ import { join as join8 } from "path";
1131
1044
  var RATE_FILE = "rate-limits.json";
1132
1045
  var MAX_EVENTS = 1e4;
1133
1046
  function getStorePath2(harnessDir) {
1134
- return join9(harnessDir, "memory", RATE_FILE);
1047
+ return join8(harnessDir, "memory", RATE_FILE);
1135
1048
  }
1136
1049
  function loadRateLimits(harnessDir) {
1137
1050
  const storePath = getStorePath2(harnessDir);
1138
- if (!existsSync9(storePath)) {
1051
+ if (!existsSync8(storePath)) {
1139
1052
  return { events: [], updated: (/* @__PURE__ */ new Date()).toISOString() };
1140
1053
  }
1141
1054
  try {
1142
- const content = readFileSync8(storePath, "utf-8");
1055
+ const content = readFileSync7(storePath, "utf-8");
1143
1056
  const parsed = JSON.parse(content);
1144
1057
  if (typeof parsed === "object" && parsed !== null && "events" in parsed && Array.isArray(parsed.events)) {
1145
1058
  return parsed;
@@ -1150,8 +1063,8 @@ function loadRateLimits(harnessDir) {
1150
1063
  }
1151
1064
  }
1152
1065
  function saveRateLimits(harnessDir, store) {
1153
- const memoryDir = join9(harnessDir, "memory");
1154
- if (!existsSync9(memoryDir)) {
1066
+ const memoryDir = join8(harnessDir, "memory");
1067
+ if (!existsSync8(memoryDir)) {
1155
1068
  mkdirSync5(memoryDir, { recursive: true });
1156
1069
  }
1157
1070
  if (store.events.length > MAX_EVENTS) {
@@ -1296,8 +1209,8 @@ function checkGuardrails(harnessDir, config) {
1296
1209
  import { tool as aiTool, jsonSchema } from "ai";
1297
1210
 
1298
1211
  // src/runtime/tools.ts
1299
- import { existsSync as existsSync10 } from "fs";
1300
- import { join as join10 } from "path";
1212
+ import { existsSync as existsSync9 } from "fs";
1213
+ import { join as join9 } from "path";
1301
1214
  function extractAuth(body) {
1302
1215
  const authSection = body.match(/## Authentication\s*\n([\s\S]*?)(?=\n## |\n$|$)/i);
1303
1216
  if (!authSection) return [];
@@ -1364,8 +1277,8 @@ function parseToolDefinition(doc) {
1364
1277
  };
1365
1278
  }
1366
1279
  function loadTools(harnessDir) {
1367
- const toolsDir = join10(harnessDir, "tools");
1368
- if (!existsSync10(toolsDir)) return [];
1280
+ const toolsDir = join9(harnessDir, "tools");
1281
+ if (!existsSync9(toolsDir)) return [];
1369
1282
  const docs = loadDirectory(toolsDir);
1370
1283
  return docs.map(parseToolDefinition);
1371
1284
  }
@@ -1789,7 +1702,7 @@ function validateMcpConfig(config) {
1789
1702
  // src/core/harness.ts
1790
1703
  function createHarness(options) {
1791
1704
  const dir = resolve(options.dir);
1792
- if (!existsSync11(dir)) {
1705
+ if (!existsSync10(dir)) {
1793
1706
  throw new Error(`Harness directory not found: ${dir}`);
1794
1707
  }
1795
1708
  const config = loadConfig(dir, options.config);
@@ -2138,8 +2051,6 @@ function createHarness(options) {
2138
2051
  }
2139
2052
 
2140
2053
  export {
2141
- loadConfig,
2142
- writeDefaultConfig,
2143
2054
  createLogger,
2144
2055
  setGlobalLogLevel,
2145
2056
  getGlobalLogLevel,
@@ -2209,4 +2120,4 @@ export {
2209
2120
  validateMcpConfig,
2210
2121
  createHarness
2211
2122
  };
2212
- //# sourceMappingURL=chunk-GUJTBGVS.js.map
2123
+ //# sourceMappingURL=chunk-MSO7DKBK.js.map